<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:10pt"><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;">Hi Luis,<br><br>Thanks for explaining this. Ive just managed to do the<br>same with vtk and tcl. However vtk's ImageViewer only<br>supports RGB or transformations to grayscale using<br>SetColorWindow and SetColorLevel.<br>My images look quite different in vtk so I think it's better<br>to try ITK for this. <br>regards,<br>Lars Nygard<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Luis Ibanez <luis.ibanez@kitware.com><br>To: Lars Nygard <lnygard@yahoo.com><br>Cc: insight-users@itk.org<br>Sent: Tuesday, August 14, 2007 11:06:53 AM<br>Subject: Re: [Insight-users] Generating Imag from Histogram using Intensity Function<br><br><br>Hi
Lars,<br><br>Thanks for your detailed description of the problem.<br><br><br>The difficulty that you are facing is due to the fact that the <br><br> itk::ScalarImageToHistogramGenerator<br><br> *IS NOT* a pipeline filter.
<br><br><br>You are using it under the assumption that Update()<br>calls will propagate through this class. This is not the case.<br><br>This class is equivalent to a "Calculator".<br><br>Please read carefully the description of this class in the
<br>ITK Software Guide<br><br> <a rel="nofollow" target="_blank" href="http://www.itk.org/ItkSoftwareGuide.pdf">http://www.itk.org/ItkSoftwareGuide.pdf</a><br><br>---<br><br>I order to use it properly you must do the following:<br><br>1) Call Update() on the filter that is going to provide the
<br> input to the histogram generator<br><br>2) Set the parameters of the histogram <br> - Number of bins<br> - minimum <br> - maximum<br><br>3) Call "Compute() on the histogram generator<br><br>4) Get the output and pass it to a subsequent filter
<br> e.g. the HistogramToImage filter<br><br>5) Call Update() on that downstream filter.<br><br><br>Note also that if your input image has a single<br>component per pixel (e.g. it is a Scalar image),<br>then its Histogram will be a 1-dimensional array,
<br>and when you use the HistogramToImage filter<br>you will get an image of dimensions <br><br> NumberOfBins X 1<br><br>If your purpose was to plot the histogram, you<br>may want to rather use the histogram bin
<br>iterator in order to recover the count values<br>from the bins. (as shown in the attached example).<br><br>-------------------------------------------------------------------<br>Note that the ITK Statistics Framework is currently
<br>being refactored. As part of this refactoring effort,<br>most "Generator" and "Calculator" classes have been<br>converted into actual pipeline filters. You will find<br>information about the refactoring at the Wiki page:
<br><a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007">http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007</a><br><br>The description of the new framework can be seen at:
<br><a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_New_Statistics_Framework">http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_New_Statistics_Framework</a><br><br>The migration guide is available at:
<br><a rel="nofollow" target="_blank" href="http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_Migration_Users_Guide">http://www.itk.org/Wiki/Proposals:Refactoring_Statistics_Framework_2007_Migration_Users_Guide</a><br><br>The source code of the refactored Framework is available at:
<br><a rel="nofollow" target="_blank" href="http://www.na-mic.org/svn/NAMICSandBox/trunk/ITKStatisticsPipelineRefactoring/">http://www.na-mic.org/svn/NAMICSandBox/trunk/ITKStatisticsPipelineRefactoring/</a><br>-------------------------------------------------------------------
<br><br><br>The refactored version of the Statistics Framework is currently<br>experimental, and will NOT be included in ITK before the release of ITK 3.4.<br><br><br>In the meantime, please find attached the source code
<br>of your example, after all these issues have been fixed.<br>(using the current ITK CVS version).<br><br><br>Please give it a try and let us know if you have<br>any questions,<br><br><br> Thanks<br><br><br> Luis
<br><br><br><br>-------------------------------------------------------------------------<br><div><span class="gmail_quote">On 8/14/07, <b class="gmail_sendername">Lars Nygard</b> <<a rel="nofollow" target="_blank" href="mailto:lnygard@yahoo.com">lnygard@yahoo.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi all,<br><br>Im trying to make an applet where I scroll through an image and
<br>where I can see the histogram of every slice. However Im getting<br>an error from windows when I try to update the HistogramToIntensityImageFilter.<br>Im first trying with a 2D png image.<br>Ive tried to catch the error but windows is giving an error and I don't know what's
<br>wrong. The code is bellow. Anybody got an idea what's wrong??<br>thanks,<br>Lars Nygard<br><br>//Declare input Image<br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 2;<br> typedef unsigned char MeasurementType ;
<br> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::Image< unsigned char, 2> BinImageType;<br><br> //reader<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();
<br> reader->SetFileName( "BrainSliceT1.png" );<br><br> //code for generating the histogram<br> typedef itk::Statistics::ScalarImageToHistogramGenerator< ImageType > HistogramGenType;<br> typedef HistogramGenType::HistogramType HistogramType;
<br> HistogramGenType::Pointer genhistogram = HistogramGenType::New();<br> genhistogram->SetNumberOfBins( 256 );<br><br> //code for converting histogram to image<br> typedef itk::HistogramToIntensityImageFilter< HistogramType > HistogramToImageType;
<br> HistogramToImageType::Pointer histToImage = HistogramToImageType::New();<br><br><br> //pipeline<br> genhistogram->SetInput( reader->GetOutput() );<br> histToImage->SetInput( genhistogram->GetOutput() );
<br> reader->Update();<br><br>//here windows gives an error and the program aborts<br> try<br> {<br> histToImage->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception thrown while reading image" << excp << std::endl;
<br> }<br><br><br><br><br><br>_________________________________________________________<br>Alt i én. Få Yahoo! Mail med adressekartotek, kalender og<br>notisblokk. <a rel="nofollow" target="_blank" href="http://no.mail.yahoo.com">http://no.mail.yahoo.com
</a><br>_______________________________________________<br>Insight-users mailing list<br><a rel="nofollow" target="_blank" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br><a rel="nofollow" target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users
</a><br></blockquote></div><br>
</div><br></div></div><br>
<hr size=1><br><table><tr><td>Alt i én. Få <a href=http://no.mail.yahoo.com>Yahoo! Mail</a> med adressekartotek, kalender og notisblokk.</td></tr></table></body></html>