[Insight-users] itk/vtk rgb/luminance translation confusion

Rishi Graham rishig at soe.ucsc.edu
Wed Sep 4 18:15:44 EDT 2013


Hello,

I am a complete itk/vtk noob.  Please excuse the vague title, I am absolutely baffled as to exactly where my code is going wrong.  For this reason, I am also unsure how to search the insight-users archive for similar issues (although I have tried).  I admit, it's been a while since I was regularly coding in c++, so there is probably a very simple mistake somewhere.  I am trying to do something I think is fairly simple and getting results I was not expecting.  The code, input, and output screenshots are attached.  I'm running this on a Mac (OS 10.8.4), with ITK version 4.4.1, VTK6.0.0.  Here is a rundown of what I'm trying to do and what's unexpected.

The goal is to produce a vtkRenderWindow with 2 images as follows.  
Image1:
1) loaded from jpeg as an rgb image
2) run through ImageToVTKImageFilter (with a flip filter to get the orientation right)
3) rendered and displayed (as the "raw" input data)

Image2:
1) loaded from jpeg as an rgb image
2) run through an RGBToLuminanceFilter
3) cast back into RGB with CastImageFilter
4) run through  ImageToVTKImageFilter (with a flip filter to get the orientation right)
5) rendered and displayed (as the "processed" output data)

I expect that Image1 will look like the original jpg, while Image2 will just be a greyscale version of the original.  This happens as expected when the input files contain different pictures (attached "GoodOutput.png").  However, if I load the same jpg file in step 1 for both images, then what I see is the expected (greyscale) output in the Image2 slot, and a flipped version of the greyscale image in the Image1 slot ("BadOutput.png").  This same result holds if I duplicate the file and pass in the two different (but identical) input files.  Any idea where I have gone wrong?  

I set this up as a simple test case, my ultimate goal is to extract an ROI from an RGB image, processing it as grayscale, then placing the result back into the original (color) image.  If there is a better way to go about this, I'd love to know!

Thank you for your time,
-Rishi.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0006.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testCase.cxx
Type: application/octet-stream
Size: 4865 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0007.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UmbrellaThumb.jpg
Type: image/jpg
Size: 27833 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0004.jpg>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0008.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GardenThumb.jpg
Type: image/jpg
Size: 12265 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0005.jpg>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0009.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GoodOutput.jpg
Type: image/jpg
Size: 45359 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0006.jpg>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0010.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BadOutput.jpg
Type: image/jpg
Size: 42597 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0007.jpg>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130904/431b8016/attachment-0011.htm>


More information about the Insight-users mailing list