On Mon, Dec 3, 2012 at 12:24 PM, Bill Lorensen <<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>> wrote:<br>><br>> David,<br>><br>> Is this using itkv4. Looks like it was fixed tor itkv4 but I have not<br>
> tested it yet.<br>><br>> Bill<br><br>Ok, I guess it is not the exact same problem, but it seems very similar. If I read a 4 channel (RGBA) png into an Image<unsigned char, 2> and write it out again, I get a 1 channel image that looks just like the original image (the original image was binary (only had values (255 0 0 0) and (0 0 0 0))).<br>
<br>However, I read a 2 channel png (gray, alpha) into an Image<unsigned char, 2> and write it out again, the result is a black image.<br><br>Using the attached GrayAlpha.png as input and running the following will produce the all black GrayAlphaOutput.png (also attached).<br>
<br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br><br>int main(int argc, char *argv[])<br>{<br> if(argc < 3)<br> {<br> std::cerr << "Required: input output" << std::endl;<br>
<br> return EXIT_FAILURE;<br> }<br><br> std::string inputFilename = argv[1];<br> std::string outputFilename = argv[2];<br><br> typedef itk::Image< unsigned char, 2 > ImageType;<br><br> typedef itk::ImageFileReader<ImageType> ReaderType;<br>
ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName(inputFilename);<br> reader->Update();<br><br> typedef itk::ImageFileWriter<ImageType> WriterType;<br> WriterType::Pointer writer = WriterType::New();<br>
writer->SetFileName(outputFilename);<br> writer->SetInput(reader->GetOutput());<br> writer->Update();<br>}<br><br><br>David