<div dir="ltr">Image Watch during debugging in Visual Studio.<br>Windows Photo Viewer after results dumped to disk. <br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-14 15:35 GMT+03:00 Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">How are you displaying the unsigned short image? Many viewers cannot properly display unsigned short.</p><div class="HOEnZb">
<div class="h5">
<div class="gmail_quote">On Aug 14, 2014 7:23 AM, "Мар'ян Климов" <<a href="mailto:nekto1989@gmail.com" target="_blank">nekto1989@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Hi,<br><div><br>I've tried different methods. Reading to RGBPixel<unsigned char>, then using RGBToLuminanceImageFilter and MultiplyImageFilter (2 ^ 8) produces the same visually proper image. Reading directly to <unsigned short, 2> fails. Looks like this is bug in TIFFImageIO and not in the way it is being called. <a href="http://itk-users.7.n7.nabble.com/TiffIO-strange-behaviour-td32215.html" target="_blank">http://itk-users.7.n7.nabble.com/TiffIO-strange-behaviour-td32215.html</a><br>


<br></div><div>Marian<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-13 23:55 GMT+03:00 Мар'ян Климов <span dir="ltr"><<a href="mailto:nekto1989@gmail.com" target="_blank">nekto1989@gmail.com</a>></span>:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Matt,<br><br></div>I hope this is proper cmakelists.txt. I'm used to using ITK connected through *.props into Visual Studio solution.<br>


<br></div>Best regards,<br></div>Marian<br><br></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-13 22:52 GMT+03:00 Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span>:<div>


<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Marian,<br>
<br>
Thanks for the update.  Offhand, I am not seeing the issue.<br>
<br>
Could you please post a SSCCE [1], i.e. CMakeLists.txt, the code, and<br>
the input data?<br>
<br>
Thanks,<br>
Matt<br>
<br>
[1] <a href="http://sscce.org/" target="_blank">http://sscce.org/</a><br>
<div><div><br>
On Wed, Aug 13, 2014 at 2:27 PM, Мар'ян Климов <<a href="mailto:nekto1989@gmail.com" target="_blank">nekto1989@gmail.com</a>> wrote:<br>
> {<br>
>     typedef unsigned short PixelType;<br>
>     typedef itk::Image<PixelType, 2> ImageType;<br>
>     auto reader = itk::ImageFileReader<<br>
> ImageType>::New();<br>
>     reader->SetFileName("D:/TestData/input/input.tif");<br>
>     reader->SetImageIO(itk::TIFFImageIO::New());<br>
><br>
>     typedef unsigned short OutputPixelType;<br>
>     typedef itk::Image<OutputPixelType, 2> OutputImageType;<br>
><br>
>     auto writer = itk::ImageFileWriter<OutputImageType>::New();<br>
>     writer->SetFileName("D:/TestData/output/ushort_to_ushort.tif");<br>
>     auto image_io = itk::TIFFImageIO::New();<br>
>     image_io->SetPixelType(itk::ImageIOBase::SCALAR);<br>
>     writer->SetImageIO(image_io);<br>
>     writer->SetInput(reader->GetOutput());<br>
>     writer->Update(); //produces completely black<br>
>     }<br>
><br>
>     {<br>
>     typedef itk::RGBAPixel<char> PixelType;<br>
>     typedef itk::Image<PixelType, 2> ImageType;<br>
>     auto reader = itk::ImageFileReader<ImageType>::New();<br>
>     reader->SetFileName("D:/TestData/input/input.tif");<br>
>     reader->SetImageIO(itk::TIFFImageIO::New());<br>
>     reader->Update();<br>
><br>
>     typedef unsigned short OutputPixelType;<br>
>     typedef itk::Image<OutputPixelType, 2> OutputImageType;<br>
><br>
>     auto input_image = reader->GetOutput();<br>
>     auto output_image = OutputImageType::New();<br>
>     output_image->CopyInformation(input_image);<br>
>     output_image->SetRegions(input_image->GetLargestPossibleRegion());<br>
>     output_image->Allocate();<br>
>     itk::ImageRegionConstIterator<ImageType> const_iterator(input_image,<br>
> input_image->GetLargestPossibleRegion());<br>
>     itk::ImageRegionIterator<OutputImageType><br>
> rescaled_iterator(output_image, output_image->GetLargestPossibleRegion());<br>
>     for (const_iterator.GoToBegin(), rescaled_iterator.GoToBegin();<br>
> !const_iterator.IsAtEnd(); ++const_iterator, ++rescaled_iterator)<br>
>       {<br>
>       const PixelType& pixel = const_iterator.Get();<br>
>       rescaled_iterator.Set(((pixel.GetAlpha() * 16 + pixel.GetRed()) * 16 +<br>
> pixel.GetGreen()) * 16 + pixel.GetBlue());<br>
>       }<br>
><br>
>     auto writer = itk::ImageFileWriter<OutputImageType>::New();<br>
>     writer->SetFileName("D:/TestData/output/rgba_char_to_ushort.tif");<br>
>     auto image_io = itk::TIFFImageIO::New();<br>
>     image_io->SetPixelType(itk::ImageIOBase::SCALAR);<br>
>     writer->SetImageIO(image_io);<br>
>     writer->SetInput(output_image);<br>
>     writer->Update(); //output looks the same<br>
>     }<br>
><br>
><br>
> 2014-08-13 20:50 GMT+03:00 Matt McCormick <<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>>:<br>
>><br>
>> Hi Marian,<br>
>><br>
>><br>
>> If<br>
>><br>
>>   itk::Image< unsigned  short, 2 ><br>
>><br>
>> is used for the ImageType, does it work (note the dimension<br>
>> specification).<br>
>><br>
>> HTH,<br>
>> Matt<br>
>><br>
>> On Wed, Aug 13, 2014 at 1:47 PM, Мар'ян Климов <<a href="mailto:nekto1989@gmail.com" target="_blank">nekto1989@gmail.com</a>><br>
>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > How to properly read 32-bit TIFF? I need to get itk::Image<unsigned<br>
>> > short><br>
>> > on output. If I use it as ImageType for ImageFileReader, it is read as<br>
>> > fully<br>
>> > black (checked contrast with Image Watch and it is for sure completely<br>
>> > empty). If I read it with pixel type RGBPixel<unsigned char> or<br>
>> > RGBAPixel<unsigned char>, it is read properly. But I need to convert it<br>
>> > manually to unsigned short after this. So what is the proper way of<br>
>> > reading<br>
>> > it? Do I need to create templated methods for every pixeltype with<br>
>> > conversions to unsigned short?<br>
>> ><br>
>> > Best regards,<br>
>> > Marian<br>
>> ><br>
>> > _______________________________________________<br>
>> > Community mailing list<br>
>> > <a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
>> > <a href="http://public.kitware.com/mailman/listinfo/community" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div></div></div><br></div>
</blockquote></div><br></div>
<br>_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org" target="_blank">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
<br></blockquote></div>
</div></div></blockquote></div><br></div>