[Insight-users] ConnectedThresholdImageFilter does take into accopunt the configuration

Daanen Vincent daanen at koelis.com
Wed Oct 7 02:17:12 EDT 2009


Hi Itk users,

I want to use itk::ConnectedThresholdImageFilter to extract a object from a
3D image.
I first load the image and convert it from our own image format into itk
image format. The call to CItkInterface::Gmcao2Itk is just a wrapper to
ItkImageimportFilter. 
I can say it is ok (I play several tests to check that all the data are
correctly converted...)

I then instantiate a itk::ConnectedThresholdImageFilter ,set its input, the
thresholds and the seed. (My code is nearly the same that the one in the itk
user guide)

When I call Update, the software crashes with messages in a window but I
can't read them totally ...:(

So, before calling update, I print the component on screen (using Print
method) and I can see that the thresholds are not the one I set (low = 0;
high = 255) instead of (L/H = 100/130).
I also saw that there is not method to set the connectivity unless itk is
compiled with ITK_USE_REVIEW. Is this normal ? I can not see why the
connectivity is link to the REVIEW flag 

How can I find why the filter exit without making its work ?

Thx for help

Vince

PS : the code I wrote. If someone sees something wrong, please tell me

void Test()
{

/// Our Own core work
	typedef gmcao::CImage<BYTE,3> TImage;
	CSmartPtr<TImage> l_pImg(new TImage);

	if (!gmcao::CImageTools<TImage>::ReadImage(*l_pImg,"Img.hdr"))
	{
		std::cout<<"Could not read image"<<std::endl;
		return;
	}

	typedef CItkInterface<TImage::TValue, TImage::Dim> TItkInterface;
	TItkInterface::TItkImage::Pointer l_pIktImg =
TItkInterface::Gmcao2Itk(*l_pImg);
	if (l_pIktImg.IsNull())
	{	
		std::cout<<"Error converting Gmcao -> Itk"<<std::endl;
		return;
	}
/// 

/// Itk filter
	typedef
itk::ConnectedThresholdImageFilter<TItkInterface::TItkImage,TItkInterface::T
ItkImage> TFilter;
	TFilter::Pointer l_pFilter=TFilter::New();
	if (l_pFilter.IsNull())
	{	
		std::cout<<"Could not create filter"<<std::endl;
		return;
	}

	l_pFilter->SetInput(l_pIktImg);
	l_pFilter->SetLower(100);
	l_pFilter->SetUpper(130);

	TFilter::IndexType l_Seed;
	l_Seed[0] = l_pImg->GetWidths()[0]>>1;
	l_Seed[1] = l_pImg->GetWidths()[1]>>1;
	l_Seed[2] = l_pImg->GetWidths()[2]>>1;

	l_pFilter->SetSeed(l_Seed);

	l_pFilter->DebugOn();
	l_pFilter->Print(std::cout);

	try
	{		l_pFilter->Update();}
	catch( itk::ExceptionObject &excep )
	{
		std::cerr << "Exception caught !" << std::endl;
		std::cerr << excep << std::endl;
	}
}

--------------------------------------------
Vincent Daanen, PhD
D&D Manager

--------------------------------------------
KOELIS
5, avenue du Grand Sablon 38700 La Tronche
www.koelis.com  -  daanen at koelis.com
Tel .+33(0) 476637588 Fax .+33(0) 476637592
--------------------------------------------

CONFIDENTIALITY This e-mail and any attachments are confidential and may
also be privileged. If you are not the named recipient, please notify the
sender immediately and do not disclose the contents to another person, use
it for any purpose, or store or copy the information in any medium.

"Les problèmes ne peuvent être résolus par ceux dont l'horizon se limite aux
réalités quotidiennes,  mais par ceux qui rêvent de choses qui n'ont jamais
existé et qui se disent : Pourquoi Pas ?" (J-F Kennedy, 1963). 



More information about the Insight-users mailing list