[Insight-users] ConnectedThresholdImageFilter does take into accopunt the configuration
Daanen Vincent
daanen at koelis.com
Thu Oct 8 09:32:37 EDT 2009
Hi Luis,
Thanks for your input.
> An easy way to verify this, would be to pass the image to
> an itkImageFileWriter<> and to save it to disk.
I follow your requirement and thus, i could write my image on the disk ...I
checked the image and it is ok.
> BTW: It is normal for the connected threshold filter not to
> offer the full connectivity option when ITK has been configured
> with REVIEW off. The reason is that this is a new feature, that
> relies on a new Iterator class that is currently in the Code/Review
> directory.
OK
> In particular, you want to review the code of
>
> TItkInterface::Gmcao2Itk(*l_pImg);
>
> and make sure that the ITK image produced by the ImportFilter
> is held ALL THE TIME by a SmartPointer.
Yes it is
>
> Also, please double check the settings of the boolean flag that
> defines who will be responsible for releasing the memory of
> the imported image. (Wrongly setting this boolean is also
> a common mistake when importing images).
The application is responsible for releasing the memory of
> the imported image and since I can write the imported image on the disk ,I
think it's ok.
The crash occurs on the following line:
l_pFilter->Update();
So during the filter processing I guess ....
Hereafter the output of the call to l_pFilter->Print() method:
ConnectedThresholdImageFilter (003E7E48)
RTTI typeinfo: class itk::ConnectedThresholdImageFilter<class
itk::Image<unsigned char,3>,class itk::Image<unsigned char,3> >
Reference Count: 1
Modified Time: 53
Debug: On
Observers:none
Number Of Required Inputs: 1
Number Of Required Outputs: 1
Number Of Threads: 2
ReleaseDataFlag: Off
ReleaseDataBeforeUpdateFlag: Off
Input 0: (003EA538)
Input 1: (003E81C8)
Input 2: (003ECF80)
Output 0: (003E7F28)
AbortGenerateData: Off
Progress: 0
Multithreader:
RTTI typeinfo: class itk::MultiThreader
Reference Count: 1
Modified Time: 27
Debug: Off
Observers:
none
Thread Count: 2
Global Maximum Number Of Threads: 128
Global Default Number Of Threads: 2
Upper: 255
Lower: 0
ReplaceValue: 1
Connectivity: 0
As you can see, Lower/Upper = [0 255] but I explicitly set them to 100/130
Debug is also OFF but I set it to on just before the call to Print ...
Any Idea ?
Vincent
>
>
>
> Regards,
>
>
> Luis
>
>
> ------------------
> On Wed, Oct 7, 2009 at 2:17 AM, Daanen Vincent
> <daanen at koelis.com> wrote:
> > 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,TI
> tkInterface::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).
> >
> > _____________________________________
> > Powered by 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