<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Matt,<div><br></div><div>Thank you for looking at this. &nbsp;I did see that I can do it inline, but it really seemed less than optimal to have to repeat all that code at the top level. &nbsp;After playing with it a bit, it is clear that the problem lies in the setupForVTK function (I created a simpler test case which only calls setupForVTK on both files and it still has the same issue). &nbsp;I'm still not entirely sure what I was doing wrong. &nbsp;I tried creating the vtkSmartPointer in main and passing it in, but it did not help. &nbsp;</div><div><br></div><div>Anyway, I did find that I can work around this by using ImageToVTKImageFilter &nbsp;into vtkImageFlip instead of FlipImageFilter into ImageToVTKImageFilter (code follows).</div><div><br></div><div>Thanks again for your help!</div><div>-Rishi.</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">vtkSmartPointer&lt;vtkImageData&gt; setupVTKthenFlip(tmfIOImageType::Pointer imageIn){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; <span style="color: #bb2ca2">typedef</span> itk::ImageToVTKImageFilter&lt;tmfIOImageType&gt;&nbsp; ConnectorType;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; <span style="color: #bb2ca2">typedef</span> vtkSmartPointer&lt;vtkImageFlip&gt; flipType;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; vtkSmartPointer&lt;vtkImageData&gt; connectorOutput;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; ConnectorType::Pointer connector = ConnectorType::New();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; connector-&gt;SetInput(imageIn);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; connector-&gt;Update();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; connectorOutput = connector-&gt;GetOutput();</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; ">&nbsp;&nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; flipType flipFilter = flipType::New();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; flipFilter-&gt;SetFilteredAxis(<span style="color: #272ad8">1</span>); <span style="color: #008400">// flip y axis</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; flipFilter-&gt;SetInputDataObject(<span style="color: #272ad8">0</span>,connectorOutput);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; flipFilter-&gt;Update();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">&nbsp; &nbsp; <span style="color: #bb2ca2">return</span>(flipFilter-&gt;GetOutput());</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">}</div></div><div><br></div><div><br></div><div><div><div>On Sep 17, 2013, at 4:12 PM, Matt McCormick &lt;<a href="mailto:matt.mccormick@kitware.com">matt.mccormick@kitware.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Rishi,<br><br>I believe there is an error in how the vtkSmartPointer's are being<br>passed around the functions. &nbsp;If the code is moved out of the<br>functions to inline, it appears to work correctly.<br><br>HTH,<br>Matt<br><br>On Wed, Sep 4, 2013 at 10:15 PM, Rishi Graham &lt;<a href="mailto:rishig@soe.ucsc.edu">rishig@soe.ucsc.edu</a>&gt; wrote:<br><blockquote type="cite">Hello,<br><br>I am a complete itk/vtk noob. &nbsp;Please excuse the vague title, I am<br>absolutely baffled as to exactly where my code is going wrong. &nbsp;For this<br>reason, I am also unsure how to search the insight-users archive for similar<br>issues (although I have tried). &nbsp;I admit, it's been a while since I was<br>regularly coding in c++, so there is probably a very simple mistake<br>somewhere. &nbsp;I am trying to do something I think is fairly simple and getting<br>results I was not expecting. &nbsp;The code, input, and output screenshots are<br>attached. &nbsp;I'm running this on a Mac (OS 10.8.4), with ITK version 4.4.1,<br>VTK6.0.0. &nbsp;Here is a rundown of what I'm trying to do and what's unexpected.<br><br>The goal is to produce a vtkRenderWindow with 2 images as follows.<br>Image1:<br>1) loaded from jpeg as an rgb image<br>2) run through ImageToVTKImageFilter (with a flip filter to get the<br>orientation right)<br>3) rendered and displayed (as the "raw" input data)<br><br>Image2:<br>1) loaded from jpeg as an rgb image<br>2) run through an RGBToLuminanceFilter<br>3) cast back into RGB with CastImageFilter<br>4) run through &nbsp;ImageToVTKImageFilter (with a flip filter to get the<br>orientation right)<br>5) rendered and displayed (as the "processed" output data)<br><br>I expect that Image1 will look like the original jpg, while Image2 will just<br>be a greyscale version of the original. &nbsp;This happens as expected when the<br>input files contain different pictures (attached "GoodOutput.png").<br>However, if I load the same jpg file in step 1 for both images, then what I<br>see is the expected (greyscale) output in the Image2 slot, and a flipped<br>version of the greyscale image in the Image1 slot ("BadOutput.png"). &nbsp;This<br>same result holds if I duplicate the file and pass in the two different (but<br>identical) input files. &nbsp;Any idea where I have gone wrong?<br><br>I set this up as a simple test case, my ultimate goal is to extract an ROI<br>from an RGB image, processing it as grayscale, then placing the result back<br>into the original (color) image. &nbsp;If there is a better way to go about this,<br>I'd love to know!<br><br>Thank you for your time,<br>-Rishi.<br><br><br><br><br><br><br><br>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br><br></blockquote></blockquote></div><br></div></body></html>