[Insight-users] Problems with Sobel filter

C.Cagatay Bilgin bilgic at cs.rpi.edu
Mon Mar 30 15:05:26 EDT 2009


Hi, have a look at the software guide chapters 6.2 and 6.3.
You can use the CastImageFilter for this purpose.

The problem is that TPixel in your case is something other
than float or double and you use that type to define the OutputImageType
and get a warning because sobeledgedetector expects floating point.

One solution is that the caller of this method can use double as TPixel,
and the image you provide to this method can be result of the  
CastImageFilter.

Another way is to define input and output pixel types separately
and use the corresponding pixel type when you are declaring the
output & input image types.

C.Cagatay Bilgin,

On Mar 30, 2009, at 4:36 AM, doege at mi.fu-berlin.de wrote:

> Hello,
>
> I am kind of helpless, I am trying to implement a sobel filter and  
> getting the following error messages:
> I already tried to cast manual but this doesn´t work either. Some  
> how I need to cast the image(dicom) but I don´t know where and how,  
> can anyone give me some adwise?
> -------------------------------
> WARNING: In c:\insighttoolkit-3.8.0\source\code\basicfilters 
> \itkSobelEdgeDetectionImageFilter.txx, line 95
> SobelEdgeDetectionImageFilter (06D6A7F0): Output pixel type MUST be  
> float or double to prevent computational errors
>
> -------------------------------
> template < typename TPixel, unsigned int VImageDimension >
> void RegionGrowing( itk::Image<TPixel, VImageDimension>* itkImage,  
> Step6* step6 )
> {
>
> 	typedef float InternalPixelType;
> 	typedef itk::Image< InternalPixelType, VImageDimension >  
> InternalImageType;
>
>   typedef itk::Image< TPixel, VImageDimension > InputImageType;  //  
> Image type
>   typedef itk::Image< TPixel, VImageDimension > OutputImageType;
>   OutputImageType::Pointer output;
>   typedef typename InputImageType::IndexType    IndexType;
> //Sobel
> 	typedef itk::SobelEdgeDetectionImageFilter< InputImageType,  
> OutputImageType > SobelFilterType;
>
>    try
>    {
>
>        // Apply Sobel Filter
>        SobelFilterType::Pointer sobelFilter = SobelFilterType::New();
>        //sobelFilter->SetInput( filter->GetOutput() );
> 	sobelFilter->SetInput((itkImage));
> 	//sobelFilter->Update();
>
>        // Write output image
> 	//output->static_cast<itk::Image<TPixel,  
> VImageDimension>*>(sobelFilter->GetOutput());
>
> 	// add output of AutomaticSegmentation to tree
>         mitk::DataTreePreOrderIterator it(step6->m_Tree);
>        step6->m_ResultNode =  
> mitk::DataTreeHelper::AddItkImageToDataTree((sobelFilter- 
> >GetOutput()), &it, "segmentation");
>
>    	step6->m_ResultImage = static_cast<mitk::Image*>(step6- 
> >m_ResultNode->GetData());
>
>
>    }
>    catch (itk::ExceptionObject & err)
>    {
>        std::cout << "ExceptionObject caught !" << std::endl;
>        std::cout << err << std::endl;
>        return;
>   }
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> _____________________________________
> 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