[Insight-users] Blank output file

Zachary Pincus zpincus at stanford.edu
Fri Jun 18 22:44:23 EDT 2004


Hello,

Displaying 16-bit (i.e. "unsigned short") greyscale files causes some  
viewers trouble -- especially PNG files (which are more rarely seen in  
the 16-bit variety.)

First, try adjusting the brightness/contrast in your viewer. It might  
be that the useful values of your image are all in the 8-bit range, and  
the viewer did not automatically scale the image properly. (Looking at  
an image with pixels in the range 0-255 when the viewer is trying to  
show some scaled version of all the values from 0-65535 generally  
produces screen output that looks "black.")

Alternately, it might be that your PNG viewer just breaks totally on  
16-bit files... this happens. You could try saving the output as a TIFF  
and using a program that's good at reading 16-bit TIFFs (The Adobe  
Photoshop family is works, if you have access to it. The ImageMagick  
"display" tool, if you've got a UNIX-ish system, is also good.)

Finally, just try reading and writing the images as 8-bit for your  
test. All viewers deal with 8-bit images fine. This would involve  
changing the following:
>  typedef itk::Image< unsigned short, 2 > ImageType;
to
>  typedef itk::Image< unsigned char, 2 > ImageType;

Finally, note that you could have gotten an answer to this question  
much faster by searching the ITK list archives, courtesy of Google:
http://www.google.com/advanced_search? 
as_sitesearch=www.itk.org&as_epq=insight%2Dusers
"png output black" or "image output black" for example, gets you a  
bunch of messages that deal with this issue.


Zach Pincus

Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine


On Jun 18, 2004, at 3:53 PM, Jessica Ford wrote:

> Hi,
>
> I'm trying to write a simple program that read a file with  
> ImageFileReader and output the file with ImageFileWriter. I want to  
> see if it can read in "Dicom" file type.  I first run my program with  
> "png" file type. When I run my program, I get a file with no image; it  
> was all black. I don't know what's wrong. Here's my code:
>
>
> #include "itkImage.h"
> #include "itkCastImageFilter.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include <iostream>
>
> int main(int argc, char *argv[] )
> {
>  typedef itk::Image< unsigned short, 2 > ImageType;
>  typedef itk::ImageFileReader<ImageType> ReaderType;
>  typedef itk::ImageFileWriter<ImageType> WriterType;
>
>  if( argc < 2 )
>    {
>    std::cerr << "Missing Parameters " << std::endl;
>    std::cerr << "Usage: " << argv[0];
>    std::cerr << " inputFileImage  outputFileImage" << std::endl;
>    return 1;
>    }
>
>  ImageType::Pointer image = ImageType::New();
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
>
>  reader->SetFileName( argv[1] );
>  writer->SetFileName( argv[2] );
>
>  writer->SetInput( reader->GetOutput() );
>
>  try
>  {   writer->Update();
>  }
>  catch (itk::ExceptionObject & err)
>  {
> 	  std::cout << "Exception object caught! " << std::endl;
> 	  std::cout << err << std::endl;
> 	  return -1;
>  }
>
>  return 0;
> }
>
>
>
>
>
> All help would be appreciated.
>
> Jessica
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*  
> http://join.msn.com/?page=features/junkmail
>
> _______________________________________________
> 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