[Insight-users] ConnectedThresholdImageFilter does take into accopunt the configuration
Luis Ibanez
luis.ibanez at kitware.com
Wed Oct 7 10:41:57 EDT 2009
Hi Vincent,
The most common cause of crashes when importing images
from an in-house application into an ITK pipeline, are oversights
on making sure that the image is well and alive by the time it
is passed to the filter.
An easy way to verify this, would be to pass the image to
an itkImageFileWriter<> and to save it to disk.
If, when doing this, you still get a crash, then, it is quite likely
that your import process has some flaws.
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.
For more information about the process for adopting new classes
and algorithms in ITK, please look at the Wiki page:
http://www.itk.org/Wiki/ITK_Procedure_for_Contributing_New_Classes_and_Algorithms
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.
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).
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,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).
>
> _____________________________________
> 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