Hi Luis,<br><br>actually, I found the Gremlin. He sat on my shoulder all the time and told me not to set the third index for the seed point, even though I use 3-dim data (). After I <span>discovered his true intentions</span>, I took him and squeezed him under my foot, so he can never make me angry again. :-)<br>
Thank you for your help.<br><br>Regards, Michael<br><br><br><br><br><br><div class="gmail_quote">2009/8/17 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br></div>Hi Michael,<div><br></div><div>Thanks for the update.</div><div><br></div><div>
When you installed the Gremlin detectors, </div><div>I assume that you found that the </div><div><br></div><div>* Size (in pixels)</div>
<div>* Origin</div><div>* Spacing</div><div><br></div><div>of both the read Dicom image and the processed threshold image</div><div>were the same.</div><div><br></div><div>Can you confirm this ?</div><div><br></div><div>
<br>
</div><div><br></div><div>Gremlins are very vicious creatures, and if they know that you are</div><div>a C# or Java developer who is adventuring into the C++ heaven, </div><div>they will do whatever it takes to hold you back and force you to</div>
<div>live in darkness.</div><div><br></div><div>Here are some simple C++ rules:</div><div><br></div><div>1) Leave no variables uninitialized</div><div><br></div><div>2) Use ITK Smart Pointers</div><div><br></div><div>3) Use defensive programming techniques<br>
(e.g. check for everything, even what seems to be obvious,</div><div> Gremlins love to fiddle with the aspects of your code that</div><div> you trust the most).<br><br></div><div><br></div><div>The main suspect here is the m_DicomReader class....</div>
<div><br></div><div><br></div><div>Tell us more about it....</div><div><br></div><div><br></div><div>Are you , by any chance, using the vtkKWImageIO classes ?</div><div><br><br></div><div>if so, are you using a smart pointer for holding this variable ?</div>
<div><br></div><div><br></div><div>Also, typical trace of Gremlin wizardry is that your code may </div><div>do the right thing when run in Debug, and then fail, when run</div><div>in Release. (particularly when you have uninitialized variables).</div>
<div><br></div><div><br></div><div> Be brave and stick to your C++ aspirations.</div><div><br></div><div><br></div><div>The path may be hard,</div><div>but the rewards are proportional to the suffering. </div><div>
<br></div><div><br></div><div> Regards,</div><div><br></div><div><br></div><div> Luis</div><div><br></div><div><br></div><div>-------------------------------<div><div></div><div class="h5"><br><div class="gmail_quote">
On Mon, Aug 17, 2009 at 12:07 PM, Michael Xanadu <span dir="ltr"><<a href="mailto:xanadu.michael@googlemail.com" target="_blank">xanadu.michael@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Luis,<br><br>thank you for your quick reply. You're right, usually I'm a C# & Java programmer and I'm into C++/VTK/ITK for just a few weeks. Do you really think my problems lies in uninitialized variables? <br>
I already used your "gremlin detectors" earlier, the m_Dicomreader works fine and the thresholder always produces a black output (all pixels are zero). But I think the problem really is C++ (not ITK), too. What do you think should I do? Are there special rules, when using ITK in C++ (for example, should I initialize my pipelines in a special way or something?) Are there some important C++ topics I should know about?<br>
<br>Regards, Michael<br><br><br><br><div class="gmail_quote">2009/8/17 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>></span><div><div></div><div>
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br></div>Hi Michael,<div><br></div><div><br></div><div> This is clearly the work of Gremlins!</div><div><br></div><div><br></div><div>Here are some of the typical mechanisms used by Gremlins to exasperate C++ developers</div>
<div>with the evil hope of making adopt C# or Java:</div><div><br></div><div><ul><li>Distract the C++ developer to make her/him leave some uninitialized variables<br>(You can check for uninitialized variables by using Valgrind)<br>
<br></li><li>Gremlins may have removed from your m_DicomReader class the code that<br>triggers the read of the DICOM image, so that when you call GetITKImage() <br>you get an empty image.</li></ul><div><br></div>You can install Gremlin detectors by adding a couple of lines:</div>
<div><br></div><div><ul><li><span style="border-collapse: collapse;">m_Dicomreader->GetITKOutput()->Print( std::cout );<br>before you set the image to the threshold filter<br><br></span></li>
<li><span style="border-collapse: collapse;">thresholder->GetOutput()->Print( std::cout )<br>after you call Update in the connected threshold filter.</span></li></ul></div><div><br></div><div>
<br></div><div> Regards,</div><div><br></div><div><br></div><div> Luis</div><div><br></div><div>---------------------------<br><div class="gmail_quote"><div><div></div><div>On Mon, Aug 17, 2009 at 5:26 AM, Michael Xanadu <span dir="ltr"><<a href="mailto:xanadu.michael@googlemail.com" target="_blank">xanadu.michael@googlemail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>Hallo itk users,<br><br>now take a look at some real strange bug. I programmed a ConnectedThresholdImageFilter, which works (surprisingly).<br>
But if add add some lines of QT code into the method (which don't mess with the filter) - all I get is a black output!<br>
This kind of bug has happened to me a lot lately. Sometimes a filter doesn't seem to work, I tinker around with it for a day and after the SAME code works! <br>I even have a fast marching filter which only works, if I add some lines in which I create some itk::ImageFileWriter objects (BUT I DON'T USE THEM!).<br>
And once I get a code to work, it only works in the current method/class/project. If I copy and paste the code -> black ouput!<br>Do Someone know, what went wrong?<br><br>Thanx in advance, Michael<br><br><br><br>void MyMainWindow::connectedThresholdFilter()<br>
{<br> typedef itk::ConnectedThresholdImageFilter<ImageType, ImageType> ThresholderType;<br> ThresholderType::Pointer thresholder = ThresholderType::New();<br> thresholder->SetInput( m_Dicomreader->GetITKOutput() );<br>
<br> // if I uncomment following line, I get a black output !!!!<br> //QString s1 = this->qlineedit1->text();<br><br> thresholder->SetLower(0);<br> thresholder->SetUpper(800);<br> ImageType::IndexType index;<br>
index[0] = 250;<br> index[1] = 250;<br> thresholder->SetSeed(index);<br> thresholder->SetReplaceValue(255);<br><br> try<br> {<br> thresholder->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br>
{<br> std::cerr << "Exception caught !" << std::endl;<br> std::cerr << excep << std::endl;<br> }<br><br> // Here I use a vtkImageViewer2 to show the output<br> Utility::popUpImage(thresholder->GetOutput());<br>
}<br>
<br></div></div>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>
</blockquote></div></div></div><br>
</blockquote></div><br></div></div></div>
</blockquote></div><br>