SimpleITK - how to get maximum and minimum intensity in Image?
Asked Answered
H

1

6

I have some DICOM images. I want to rescale them using IntensityWindowingImageFilter, but first, I need to know initial values of maximum and minimum intensities.

Right now, I am building WPF UI, with which I want to have some sliders to allow user to interactively input parameters for this operation. However, to have best user experience available, I need to limit scale on sliders to have maximimum and minimum that is maximum and minimum of intensity of image. In ITK, I could use MinimumMaximumImageCalculator, but I can't seem to find it in SimpleITK.

Of course, I could simply use Image.GetBufferAsXXX() and simply iterate over each pixel to find those values, but I am almost sure this is not a right way to go.

Higgledypiggledy answered 27/12, 2015 at 16:2 Comment(1)
And, BTW. can somebody add SimpleITK tag? I do not have enough reputation yet.Teodoro
H
10

One can use MinimumMaximumImageFilter. I am not sure why thing used to get minimum and maximum is a filter, but well...

Usage:

MinimumMaximumImageFilter filter = new MinimumMaximumImageFilter();
filter.Execute(image);
this.ImageHighestIntensity = filter.GetMaximum();
this.ImageLowestIntensity = filter.GetMinimum();
filter.Dispose(); 
Higgledypiggledy answered 27/12, 2015 at 16:22 Comment(2)
Glad that you have found answer to your own question. ;)Catercornered
Well, it was kind of obvious. It had happened twice or thrice before for me, that I fought some problem for a while, asked a question here, to get an answer mere minutes later. But I hope somebody might find it useful someday, so I left it here.Teodoro

© 2022 - 2024 — McMap. All rights reserved.