[Insight-users] ScalarImageTextureCalculator

Zachary Pincus zpincus at stanford.edu
Tue Mar 29 13:54:08 EST 2005

So the problem is that you have a low dynamic-range image in a higher  
dynamic range pixel type. Now, as you recall from the documentation,  
the GLCM generator builds a histogram, so it needs to know the  
appropriate range over which to build the histogram bins. It defaults  
to using the entire dynamic range of the pixel type, as  stated in the  

>  The number of histogram bins on each axis can be set (defaults to  
> 256). Also, by default the histogram min and max corresponds to the  
> largest and smallest possible pixel value of that pixel type. To  
> customize the histogram bounds for a given image, the max and min  
> pixel values that will be placed in the histogram can be set manually.

So using a short pixel type, you have 256 bins covering 2^16 values by  
default. Now, if you give the generator an image with only 256  
intensity values, all the values go into the first bin, giving you the  
degenerate results you saw.

You thus have two options:
(1) Use SetPixelMaximumMinimum() to set the range to the dynamic range  
of the pixels in *that image*. The MinimumMaximumImageCalculator class  
can find these values, or you could do so trivially yourself. This has  
the drawback of, basically, normalizing the input image for brightness.

(2) The other option is to use SetPixelMaximumMinimum() to set the  
range to the dynamic range of the pixel type that the images were  
originally stored in on disk. This information can be discovered as  
itk::ImageIOBase::IOComponentType dataType =  

IOComponentType is an enum listing the various possible data types for  
scalar pixels or vector components. You can then recover the min and  
max for these types with a big nasty switch statement. (But perhaps  
there's a better way?)

	switch(dataType) {
			case itk::ImageIOBase::UCHAR:
				min = itk::NumericTraits<unsigned char>::min();
				max = itk::NumericTraits<unsigned char>::max();
			case itk::ImageIOBase::CHAR:
				min = itk::NumericTraits<char>::min();
				max = itk::NumericTraits<char>::max();
			case itk::ImageIOBase::USHORT:
				min = itk::NumericTraits<unsigned short>::min();
				max = itk::NumericTraits<unsigned short>::max();
			case itk::ImageIOBase::SHORT:
				min = itk::NumericTraits<short>::min();
				max = itk::NumericTraits<short>::max();
			case itk::ImageIOBase::UINT:
				min = itk::NumericTraits<unsigned int>::min();
				max = itk::NumericTraits<unsigned int>::max();
			case itk::ImageIOBase::INT:
				min = itk::NumericTraits<int>::min();
				max = itk::NumericTraits<int>::max();
			case itk::ImageIOBase::ULONG:
				min = itk::NumericTraits<unsigned long>::min();
				max = itk::NumericTraits<unsigned long>::max();
			case itk::ImageIOBase::LONG:
				min = itk::NumericTraits<long>::min();
				max = itk::NumericTraits<long>::max();
			case itk::ImageIOBase::FLOAT:
				min = itk::NumericTraits<float>::min();
				max = itk::NumericTraits<float>::max();
			case itk::ImageIOBase::DOUBLE:
				min = itk::NumericTraits<double>::min();
				max = itk::NumericTraits<double>::max();

On Mar 29, 2005, at 1:43 AM, marquis2 at etu.unige.ch wrote:

>> It's extremely unlikely that a file format change *alone* would cause
>> the ImageTextureCalculator to fail, since by the time the images are
>> read into ITK, the format ceases to matter and they are just bits in a
>> buffer.
> yes but with jpeg, the pixels range from 0 to 255, with dicom from  
> -1000
> (sometimes -3000) to 1000 or more.
>> So: (1) Are the DICOM images and the JPEG images that you give to the
>> ImageFileReaders *identical* ?
> they are not identical, the jpeg come from the brodatz collection, the
> dicom are lung CT.
> If I change the pixel type from short to unsigned char, the values seem
> to be ok for the jpeg. But then I cannot deal with the dicom (all  
> pixels
> are trunkated to the 8 lesser bits.)
> Question: what should I put in SetPixelMaximumMinimum() ? I mean, if
> I want my soft to deal both type of images?
> Samuel
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users

More information about the Insight-users mailing list