[Insight-users] writing a png file

Luis Ibanez luis . ibanez at kitware . com
Wed, 25 Jun 2003 11:22:14 -0400


Hi Gwen,

It may also be that you are using an image of type
"unsigned short" and filling it with values in the
0-255 range.

Since the dynamic range of the ushort pixel actually
goes up to 65535, the values in the 0-255 range will
not be visible unless your viewer normalize the image.
(most viewer do not normalize the image intensities).

The ImageViewer in Applications/Auxiliary do normalize
the image, and show you the actual range of pixel
values.

If you are using image type with "unsigned short",
please follow Mathieu's advice with the RescaleImage
filter, but push the max value up to 65535.

Or... if your application needs can be satisfied
with values in the 0-255 range, just make sure
that you use image with pixel type "unsigned char".


Regards


   Luis

-------------------------
Mathieu Malaterre wrote:
> Gwen,
>     Are you sure the value are in a range from 0 to 255 ?
>     If not use RescaleIntensityImageFilter:
> 
> http://www . itk . org/Doxygen/html/classitk_1_1RescaleIntensityImageFilter . html 
> 
> 
>     There is also ShiftScaleImageFilter
> HTH
> mathieu
> 
> gwenael . guillard at enst-bretagne . fr wrote:
> 
>> Hi ITK users,
>>
>> I'm trying to write a png file from an image. It's writing a file with 
>> the right number of rows and columns but empty, ie black. Here is the 
>> code I'm using. DId I forget smthg? The imageViewer part is to be sure 
>> the image isn't black (and it is not)
>>
>>
>>     PNGType::Pointer imageIO = PNGType::New();
>>     
>>     ImageWriterType::Pointer writer = ImageWriterType::New();
>>     writer->SetImageIO( imageIO );
>>     writer->SetFileName( baseFilename );
>>  
>>
>>     writer->SetInput( m_Output ); // m_Output is the image to write
>>     writer->Write();
>>
>>     ImageViewerType::Pointer imageViewer = ImageViewerType::New();
>>     imageViewer->SetLabel("Output Image");
>>     imageViewer->SetImage( m_Output );
>>     imageViewer->Show();
>>
>>
>> Thank you for your help,
>>
>> Gwen
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk . org
>> http://www . itk . org/mailman/listinfo/insight-users
>>
> 
>