Mercurial > hg > orthanc
comparison OrthancFramework/Sources/Images/ImageProcessing.cpp @ 4948:5f6b13202e85
fix for older gcc versions
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Mar 2022 09:44:01 +0100 |
parents | dfbe764995cf |
children | fcdf399f9fc0 |
comparison
equal
deleted
inserted
replaced
4947:dfbe764995cf | 4948:5f6b13202e85 |
---|---|
2998 } | 2998 } |
2999 } | 2999 } |
3000 } | 3000 } |
3001 } | 3001 } |
3002 | 3002 |
3003 | |
3004 namespace | |
3005 { | |
3006 // For older version of gcc, templated functors cannot be defined | |
3007 // as types internal to functions, hence the anonymous namespace | |
3008 | |
3009 struct MaximumFunctor | |
3010 { | |
3011 void operator() (uint8_t& a, const uint8_t& b) | |
3012 { | |
3013 a = std::max(a, b); | |
3014 } | |
3015 | |
3016 void operator() (uint16_t& a, const uint16_t& b) | |
3017 { | |
3018 a = std::max(a, b); | |
3019 } | |
3020 }; | |
3021 } | |
3003 | 3022 |
3023 | |
3004 void ImageProcessing::Maximum(ImageAccessor& image, | 3024 void ImageProcessing::Maximum(ImageAccessor& image, |
3005 const ImageAccessor& other) | 3025 const ImageAccessor& other) |
3006 { | 3026 { |
3007 struct F | |
3008 { | |
3009 void operator() (uint8_t& a, const uint8_t& b) | |
3010 { | |
3011 a = std::max(a, b); | |
3012 } | |
3013 | |
3014 void operator() (uint16_t& a, const uint16_t& b) | |
3015 { | |
3016 a = std::max(a, b); | |
3017 } | |
3018 }; | |
3019 | |
3020 switch (image.GetFormat()) | 3027 switch (image.GetFormat()) |
3021 { | 3028 { |
3022 case PixelFormat_Grayscale8: | 3029 case PixelFormat_Grayscale8: |
3023 ApplyImageOntoImage<uint8_t, F>(F(), image, other); | 3030 ApplyImageOntoImage<uint8_t, MaximumFunctor>(MaximumFunctor(), image, other); |
3024 return; | 3031 return; |
3025 | 3032 |
3026 case PixelFormat_Grayscale16: | 3033 case PixelFormat_Grayscale16: |
3027 ApplyImageOntoImage<uint16_t, F>(F(), image, other); | 3034 ApplyImageOntoImage<uint16_t, MaximumFunctor>(MaximumFunctor(), image, other); |
3028 return; | 3035 return; |
3029 | 3036 |
3030 default: | 3037 default: |
3031 throw OrthancException(ErrorCode_NotImplemented); | 3038 throw OrthancException(ErrorCode_NotImplemented); |
3032 } | 3039 } |