[ITK-users] max min image matrix

Mike Chinander chinander at gmail.com
Sat Aug 27 16:33:16 EDT 2016


Since the image type is unsigned char, cout is interpreting the values of
GetMaximum() and GetMinimum as chars. Cast the result to int before sending
to cout:

  std::cout << "Min: " <<
static_cast<int>(statisticsImageFilter->GetMinimum()) << std::endl;
  std::cout << "Max: " <<
static_cast<int>(statisticsImageFilter->GetMaximum()) << std::endl;


On Sat, Aug 27, 2016 at 3:04 PM, Tammy DiPrima <tammy.diprima at stonybrook.edu
> wrote:

> Hello,
>
> Is StatisticsImageFilter->GetMaximum() and GetMinimum() the ITK functions
> that calculate the max/min values in the 2D image array?
> I’m running the example code from ITKWikiExamples
> <https://github.com/lorensen/ITKWikiExamplesTarballs/raw/master/StatisticsImageFilter.tar>,
> and the output is:
>
> Mean: 23.5875
> Std.: 73.8819
> Min:
> Max: �
>
> I modified the code to write the image to file (attached).  As far as I
> can tell, statisticsImageFilter->GetMinimum() should be 0
> and statisticsImageFilter->GetMaximum() should be 255.
>
> Is GetMinimum() and GetMaximum() not the right functions?
>
> Thanks in advance
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160827/93c9e223/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3886 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160827/93c9e223/attachment.png>


More information about the Insight-users mailing list