[Insight-users] smoothing an Histogram
Luis Ibanez
luis.ibanez at kitware.com
Fri Jul 10 10:54:16 EDT 2009
Hi Raquel,
The RecursiveGaussianImageFilter is N-Dimensional,
you can run it in a 1-D image.
Just do:
typedef itk::RecursiveGaussianImageFilter<
ImageType1D, ImageType1D > SmoothingFilterType;
SmoothingFilterType::Pointer smoothingFilter =
SmoothingFilterType::New();
smoothingFilter->SetSigma( 1.5 ); // 1.5mm (change this value)
smoothingFilter->SetInput( line );
smoothingFilter->Update();
writer->SetInput( smoothingFilter->GetOutput() );
FYI:
By default the filter performs smoothing
but you could also set it to compute first
or second derivatives (if you need to).
Regards,
Luis
-----------------
Raquel Itk wrote:
> Hi Luis,
> I convert the Histogram into a 1DImage in this way:
>
> typedef unsigned short PixelType1D;
> typedef itk::GDCMImageIO ImageIOType;
> typedef itk::Image< PixelType1D, 1 > ImageType1D;
> typedef itk::Image< PixelType1D, 1 > ImageType1D_2;
> typedef itk::ImageFileReader< ImageType1D > ReaderType1D;
> typedef itk::ImageRegionIterator< ImageType1D> IteratorType;
>
> ReaderType::Pointer readerHis = ReaderType::New();
> ImageIOType::Pointer gdcmImageIOHis= ImageIOType::New();
> HistogramGeneratorType::Pointer histogramGenerator =
> HistogramGeneratorType::New();
> ReaderType1D::Pointer reader1D = ReaderType1D::New();
> ImageType1D::Pointer line = ImageType1D::New();
> ImageType1D::SizeType size1D;
> ImageType1D::IndexType pixelValue;
> ImageType1D::IndexType start1D;
> ImageType1D::RegionType region1D;
>
>
>
> void createImage(int *valoresHisto){
>
> size1D.Fill( 2286 );
> start1D.Fill( 0 );
> region1D.SetSize( size1D );
> region1D.SetIndex( start1D );
> line->SetRegions( region1D );
> line->Allocate();
>
> IteratorType lineIt(line, line->GetRequestedRegion());
>
> int i = 0;
> for (lineIt.GoToBegin(); !lineIt.IsAtEnd();
> ++lineIt)
> {
> lineIt.Set( valoresHisto[i]);
>
> i=i+1;
> }
>
>
> typedef itk::ImageFileWriter< ImageType1D > WriterType1D;
> WriterType1D::Pointer writer1D = WriterType1D::New();
> writer1D->SetFileName( "Image1D.png" );
>
> writer1D->SetInput( line );
> try
> {
> writer1D->Update();
> }
> catch (itk::ExceptionObject &e)
> {
> std::cerr << e << std::endl;
>
> }
> }
>
> Now I want to apply SmoothingRecursiveGaussianImageFilter2.cxx, but I
> have a problem because if need a 2d Image. How can I resolve it?
>
> Thanks
>
> Raquel
>
>
> 2009/7/4 Luis Ibanez <luis.ibanez at kitware.com
> <mailto:luis.ibanez at kitware.com>>
>
>
> Hi Raquel,
>
> You can convert the Histogram into a 1D Image,
> and use any of the ITK Smoothing filters on
> this 1D image, then convert the image back
> to a Histogram.
>
> See the class
> Insight/Code/Numerics/Statistics/itkHistogramToImageFilter.h
>
> and its related classes
>
> itkHistogramToEntropyImageFilter.h
> itkHistogramToIntensityImageFilter.h
> itkHistogramToLogProbabilityImageFilter.h
> itkHistogramToProbabilityImageFilter.h
>
> Then look at the section of Smoothing image filters
> in the ITK Software Guide
>
>
> http://www.itk.org/ItkSoftwareGuide.pdf
>
>
>
> Regards,
>
>
> Luis
>
>
>
> --------------------
> Raquel Itk wrote:
>
> Hi,
>
> I have computed the histogram of an image with
> Examples/Statistics/ImageHistogram2.cxx, now I want to smooth
> the array , where I have saved the values of an Histogram (
> valoresHisto[i]) because I have a lot of peaks. I would like to
> use a Gaussian method, I have been read about Gaussian but only
> for Images.
>
> while( itr != end )
>
> {
>
> valoresHisto[i]=itr.GetFrequency();
>
> ++itr;
>
> ++binNumber;
>
> ++i;
>
> }
>
> return(valoresHisto);
>
>
> Thanks
>
>
> Raquel
>
>
> ------------------------------------------------------------------------
>
> _____________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list