<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. 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. 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). I'm still not entirely sure what I was doing wrong. I tried creating the vtkSmartPointer in main and passing it in, but it did not help. </div><div><br></div><div>Anyway, I did find that I can work around this by using ImageToVTKImageFilter 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<vtkImageData> setupVTKthenFlip(tmfIOImageType::Pointer imageIn){</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">typedef</span> itk::ImageToVTKImageFilter<tmfIOImageType> ConnectorType;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">typedef</span> vtkSmartPointer<vtkImageFlip> flipType;</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> vtkSmartPointer<vtkImageData> 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; "> ConnectorType::Pointer connector = ConnectorType::New();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> connector->SetInput(imageIn);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> connector->Update();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> connectorOutput = connector->GetOutput();</div><p style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "> <br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> flipType flipFilter = flipType::New();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> flipFilter->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; "> flipFilter->SetInputDataObject(<span style="color: #272ad8">0</span>,connectorOutput);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> flipFilter->Update();</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">return</span>(flipFilter->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 <<a href="mailto:matt.mccormick@kitware.com">matt.mccormick@kitware.com</a>> 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. 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 <<a href="mailto:rishig@soe.ucsc.edu">rishig@soe.ucsc.edu</a>> wrote:<br><blockquote type="cite">Hello,<br><br>I am a complete itk/vtk noob. Please excuse the vague title, I am<br>absolutely baffled as to exactly where my code is going wrong. For this<br>reason, I am also unsure how to search the insight-users archive for similar<br>issues (although I have tried). 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. I am trying to do something I think is fairly simple and getting<br>results I was not expecting. The code, input, and output screenshots are<br>attached. I'm running this on a Mac (OS 10.8.4), with ITK version 4.4.1,<br>VTK6.0.0. 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 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. 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"). This<br>same result holds if I duplicate the file and pass in the two different (but<br>identical) input files. 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. 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>