[Insight-users] smothing and peaks of an histogram
Raquel Itk
raquelitk at gmail.com
Fri Jul 17 04:49:33 EDT 2009
Hi,
I have a problem to construct a binary image. I want to segment the lung
regions of DICOM image, so I compute a gray-level histogram, and the
gray-level that maximizes the separation between the two major peaks in the
histogram is selected as the gray-level threshold to compute the binary
image.
I compute the histogram and then I smoothing because I have a lot of peaks
in this way, I transform the values of the histogram in an Image 1d (thanks
a Luis):
int * createImage(int *valoresHisto){
//creamos la imagen 1d
size1D.Fill( 255 );
start1D.Fill( 0 );
region1D.SetSize( size1D );
region1D.SetIndex( start1D );
line->SetRegions( region1D );
line->Allocate();
IteratorType lineIt(line, line->GetRequestedRegion());
int i = 0;
//rellenamos la imagen con los valores del histograma
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;
}
smoothingFilter->SetSigma( 5 );
smoothingFilter->SetInput( line );
smoothingFilter->Update();
ImageType1D::Pointer image= smoothingFilter->GetOutput() ;
ImageType1D::ConstPointer inputImage =smoothingFilter->GetOutput() ;
ImageType1D::RegionType inputRegion =inputImage->GetBufferedRegion();
IteratorType iterator( image, inputRegion);
static int valoresSuavizado[512];
i=0;
for (iterator = iterator.Begin(); !iterator.IsAtEnd(); ++iterator)
{
std::cout<< iterator.Get()<< std::endl;
valoresSuavizado[i]=iterator.Get();
i=i+1;
}
return valoresSuavizado;
}
But I have problem with the first values, because there are higher values, I
use sigma=5.
Another question is about to calculate the threshold, somebody can suggest
me how I can compute that.
Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090717/d8d0059b/attachment.htm>
More information about the Insight-users
mailing list