Mercurial > hg > orthanc
comparison Core/Images/ImageProcessing.cpp @ 1993:e2a3ff770b48
introducing float32 images
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 14 May 2016 13:41:42 +0200 |
parents | 9161e3ef0d17 |
children | 4d099fee5eca |
comparison
equal
deleted
inserted
replaced
1992:9161e3ef0d17 | 1993:e2a3ff770b48 |
---|---|
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 template <typename SourceType> | |
79 static void ConvertGrayscaleToFloat(ImageAccessor& target, | |
80 const ImageAccessor& source) | |
81 { | |
82 for (unsigned int y = 0; y < source.GetHeight(); y++) | |
83 { | |
84 float* t = reinterpret_cast<float*>(target.GetRow(y)); | |
85 const SourceType* s = reinterpret_cast<const SourceType*>(source.GetConstRow(y)); | |
86 | |
87 for (unsigned int x = 0; x < source.GetWidth(); x++, t++, s++) | |
88 { | |
89 *t = static_cast<float>(*s); | |
90 } | |
91 } | |
92 } | |
93 | |
94 | |
78 template <typename TargetType> | 95 template <typename TargetType> |
79 static void ConvertColorToGrayscale(ImageAccessor& target, | 96 static void ConvertColorToGrayscale(ImageAccessor& target, |
80 const ImageAccessor& source) | 97 const ImageAccessor& source) |
81 { | 98 { |
82 assert(source.GetFormat() == PixelFormat_RGB24); | 99 assert(source.GetFormat() == PixelFormat_RGB24); |
83 | 100 |
84 const TargetType minValue = std::numeric_limits<TargetType>::min(); | 101 const TargetType minValue = std::numeric_limits<TargetType>::min(); |
85 const TargetType maxValue = std::numeric_limits<TargetType>::max(); | 102 const TargetType maxValue = std::numeric_limits<TargetType>::max(); |
376 { | 393 { |
377 ConvertColorToGrayscale<int16_t>(target, source); | 394 ConvertColorToGrayscale<int16_t>(target, source); |
378 return; | 395 return; |
379 } | 396 } |
380 | 397 |
398 if (target.GetFormat() == PixelFormat_Float32 && | |
399 source.GetFormat() == PixelFormat_Grayscale8) | |
400 { | |
401 ConvertGrayscaleToFloat<uint8_t>(target, source); | |
402 return; | |
403 } | |
404 | |
405 if (target.GetFormat() == PixelFormat_Float32 && | |
406 source.GetFormat() == PixelFormat_Grayscale16) | |
407 { | |
408 ConvertGrayscaleToFloat<uint16_t>(target, source); | |
409 return; | |
410 } | |
411 | |
412 if (target.GetFormat() == PixelFormat_Float32 && | |
413 source.GetFormat() == PixelFormat_SignedGrayscale16) | |
414 { | |
415 ConvertGrayscaleToFloat<int16_t>(target, source); | |
416 return; | |
417 } | |
418 | |
381 if (target.GetFormat() == PixelFormat_Grayscale8 && | 419 if (target.GetFormat() == PixelFormat_Grayscale8 && |
382 source.GetFormat() == PixelFormat_RGBA32) | 420 source.GetFormat() == PixelFormat_RGBA32) |
383 { | 421 { |
384 for (unsigned int y = 0; y < source.GetHeight(); y++) | 422 for (unsigned int y = 0; y < source.GetHeight(); y++) |
385 { | 423 { |