[Insight-users] Problem printing the ContourExtractor2D

Luis Ibanez luis.ibanez at kitware.com
Sat Mar 27 13:29:30 EDT 2010


Hi Preben,

The ExtractContours filter expect to get a segmented image as input.

Your image is not segmented yet,
so it is not a suitable input for this filter.


You may want to look at Edge Detection filters,
for example the Canny edge detector.


                Insight/Examples/Filtering/
                      CannyEdgeDetectionImageFilter.cxx

If you run this example in your input image:
http://jobc.dk/can_scene.bmp

with the following parameters:


Variance = 3
UpperThreshold = 3
LowerThreshold = 0.01


as

CannyEdgeDetectionImageFilter  \
   can_scene.bmp canny_edges_can_scene.png  3.0  3.0   .01

You get the image attached to this email.


By fine tunning the values of the Upper and Lower
threshold you can select to include more or less
of the significant edges. By fine tunning the value
of the variance you can look for edges of a particular
width of transition region.

http://en.wikipedia.org/wiki/Canny_edge_detector


      Regards,


            Luis


------------------------------------------------------
On Fri, Mar 26, 2010 at 10:23 AM, Preben <64bit at mailme.dk> wrote:
> Hi again again,
>
> Okay - I tried to evaluate the number of outputs from the input image and
> the result was zero. That's probably why the "print" doesn't work.
>
> However, I would like to extract some contours of the object, such as e.g.:
> http://jobc.dk/contourImage.png
> but how can I adjust the algorithm to generate the contours.
>
> The image I try extracting contours from is located here:
> http://jobc.dk/can_scene.bmp
>
>
> Best regards,
>
> Preben Holm
>
>
> Den 26-03-2010 10:17, Preben skrev:
>>
>> Hi again
>>
>> I've tried to change to parameter as you wrote - it compiles ;-)
>>
>> However, when I try to use the Print() method, I get an error and the
>> program terminates.
>>
>> What is wrong
>>
>>
>>
>> Best regards,
>> Preben
>>
>>
>>
>> Den 25-03-2010 15:31, Bill Lorensen skrev:
>>>
>>> Change    typedef itk::Image<  unsigned char, 3>  ImageType;
>>> to
>>>     typedef itk::Image<  unsigned char, 2>  ImageType;
>>>
>>> On Thu, Mar 25, 2010 at 5:48 AM, Preben<64bit at mailme.dk>  wrote:
>>>>
>>>> Hi again
>>>>
>>>> So far so good! But not that far actually...
>>>>
>>>> I've written this little example code here:
>>>> ----
>>>> #include<iostream>
>>>> #include<itkImage.h>
>>>> #include<itkImageFileReader.h>
>>>> #include<itkImageFileWriter.h>
>>>> #include<itkContourExtractor2DImageFilter.h>
>>>> #include<itkPolyLineParametricPath.h>
>>>>
>>>> int main() {
>>>>    typedef itk::Image<  unsigned char, 3>  ImageType;
>>>>    typedef itk::ImageFileReader<  ImageType>    ReaderType;
>>>>    typedef itk::ImageFileWriter<  ImageType>    WriterType;
>>>>    typedef itk::ContourExtractor2DImageFilter<  ImageType>
>>>>  ContourFilter;
>>>>
>>>>    ReaderType::Pointer reader  = ReaderType::New();
>>>>    WriterType::Pointer writer  = WriterType::New();
>>>>    reader->SetFileName("can_scene.bmp");
>>>>    writer->SetFileName("can_contours.png");
>>>>
>>>>    ContourFilter::Pointer filter = ContourFilter::New();
>>>>    filter->SetInput( reader->GetOutput() );
>>>>
>>>>    // Run and output data to data object
>>>>    ContourFilter::OutputPathType::Pointer path;
>>>>    filter->Update();
>>>>    path = filter->GetOutput();
>>>>
>>>>    path->Print(std::cout);
>>>> }
>>>> ----
>>>>
>>>>
>>>> but I get this strange error when compiling:
>>>> ----
>>>> C:\working\itkExample>make
>>>> [100%] Building CXX object CMakeFiles/itkTest.dir/src/main.cpp.obj
>>>> C:/working/InsightToolkit-3.16.0/Code/Common/itkConceptChecking.h: In
>>>> member
>>>> function `void itk::Concept::SameDimension<D1,
>>>> D2>::Constraints::constraints() [with unsigned int D1 = 3u, unsigned int
>>>> D2
>>>> = 2u]':
>>>> C:/working/InsightToolkit-3.16.0/Code/Common/itkConceptChecking.h:547:
>>>> instantiated from `itk::Concept::SameDimension<3u, 2u>'
>>>>
>>>> C:/working/InsightToolkit-3.16.0/Code/Review/itkContourExtractor2DImageFilter.h:158:
>>>>   instantiated from
>>>> `itk::ContourExtractor2DImageFilter<main()::ImageType>'
>>>> C:\working\itkExample\src\main.cpp:19:   instantiated from here
>>>> C:/working/InsightToolkit-3.16.0/Code/Common/itkConceptChecking.h:543:
>>>> error: conversion from
>>>> `itk::Concept::Detail::UniqueType_unsigned_int<2u>'
>>>> to non-scalar type `itk::Concept::Detail::UniqueType_unsigned_int<3u>'
>>>> requested
>>>> make[2]: *** [CMakeFiles/itkTest.dir/src/main.cpp.obj] Error 1
>>>> make[1]: *** [CMakeFiles/itkTest.dir/all] Error 2
>>>> make: *** [all] Error 2
>>>> ----
>>>>
>>>> What should I do about it?
>>>>
>>>> (I'm using Windows XP 32bit with MinGW compiler and configures ITK with
>>>> REVIEW code set to ON)
>>>>
>>>>
>>>> Best regards,
>>>>
>>>> Preben Holm
>>>>
>>>> _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://www.kitware.com/products/protraining.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
>>>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.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
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: canny_edges_can_scene.png
Type: image/png
Size: 23189 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100327/59fa441b/attachment-0001.png>


More information about the Insight-users mailing list