[Insight-users] Re: Histogram: empty bins

David Llanos gva02 at elai.upm.es
Wed, 25 Feb 2004 16:40:32 +0100


Hi Luis

I read the solution of Julien, but I don't resolve my problem. This is my
code:

----------------------------------------------------------------------------
typedef enum{ROJO,VERDE,AZUL} colorRGB;
typedef itk::Statistics::ImageToHistogramGenerator< RGBImageType >
              HistogramGeneratorType;
typedef HistogramGeneratorType::SizeType   SizeType;
typedef HistogramGeneratorType::HistogramType  HistogramType;


unsigned long * ProcesadorImagenEspermas::imhist (const RGBImageType *
ImagenEntrada, colorRGB color) {
  SizeType size;
  unsigned int channel = 0;
  if (color==VERDE) {
  channel = 1 ;  // Canal Verde
  size[0] =   1;  // Numero de bins del canal Rojo
  size[1] = 255;  // Numero de bins del canal Verde
  size[2] =   1;  // Numero de bins del canal Azul
  }
  if (color==AZUL) {
  channel = 2 ;  // Canal Azul
  size[0] =   1;  // Numero de bins del canal Rojo
  size[1] =   1;  // Numero de bins del canal Verde
  size[2] = 255;  // Numero de bins del canal Azul
  }

  HistogramGeneratorType::Pointer histogramGenerator =
HistogramGeneratorType::New();

  histogramGenerator->SetInput(ImagenEntrada);

  histogramGenerator->SetNumberOfBins( size );
  histogramGenerator->SetMarginalScale( 10.0 );
  histogramGenerator->Compute();


  //SetHistogramMin() and SetHistogramMax()         ...........as the use?

  const HistogramType * histogram = histogramGenerator->GetOutput();
  const unsigned int histogramSize = histogram->Size();

  std::cout << "Tamano del histograma " << histogramSize << std::endl;

  for( unsigned int bin=0; bin <= histogramSize; bin++ )
     Histograma[bin]=histogram->GetFrequency( bin, channel );
  return(Histograma);
}
----------------------------------------------------------------------------
----

thanks and regards,

David


----- Original Message ----- 
From: "Luis Ibanez" <luis.ibanez at kitware.com>
To: "David Llanos" <gva02 at elai.upm.es>; <Insight-users at itk.org>
Sent: Wednesday, February 25, 2004 2:21 AM
Subject: Re: Histogram: empty bins


>
>
> Hi David,
>
> What is the typedef that you used for defining
> the type HistogramGeneratorType  ?
>
> ----
>
> Please read the messages that Julien Jomier
> posted to the users-list regarding the solution
> to your problem.
>
> The user-list is indexed by Google:
>
>
http://www.google.com/advanced_search?as_sitesearch=www.itk.org&as_epq=insight%2Dusers
>
> If you search for the words:
>
>                histogram, empty, bins
>
> in 0.19 seconds Google will find the following link for you:
>
> http://www.itk.org/pipermail/insight-users/2004-January/006408.html
>
>
>
> Regards,
>
>
>     Luis
>
>
> --------------------
> David Llanos wrote:
>
> > hi Luis,
> >
> > Do you renember the problem of the empty bins in the histogram? I a lot
> > of time have been outside and I have not been able to read your messages
> > up to now.
> >
> > I have just download the last cvs ITK release yesterday, but I don't
> > know how to use the next functions correctly:     SetHistogramMin() and
> > SetHistogramMax()
> >
> > the following code is erroneous:
> >
> > --------------------------
> >  HistogramGeneratorType::Pointer histogramGenerator =
> > HistogramGeneratorType::New();
> >  histogramGenerator->SetInput(ImagenEntrada);
> >  histogramGenerator->SetNumberOfBins( size );
> >  histogramGenerator->SetHistogramMin(0);
> >                             ...
> >  ----------------------------------------------------
> > C:\Documents and Settings\dllanos.LABSISWS09\Mis
> > documentos\CLASESESPERMA\procesadorImagenEsperma.cpp(61) : error C2039:
> > 'SetHistogramMin' : is not a member of 'ImageToHistogramGenerator<class
> > itk::Image<class itk::RGBPixel<unsigned char>,2> >'
> > ------------------------------------------------------
> >
> >
> > Thanks in advange and regards;
> >
> > David
>
>
>
>