[ITK-users] problem with 3d region growing

samah bouzidi samah.bouzidi at gmail.com
Sun Feb 8 07:07:44 EST 2015


hi,

I finished the slice by slice region growing version of code. unfortunately I
have these errors:

1) no matching function for call to 'itk :: ConnectedThresholdImageFilter <
itk :: Image <short int, 2u>, itk :: Image <unsigned char, 2u>> :: SetSeed (
itk :: Image <short int, 3u> :: INDEXTYPE &) '
connectedThreshold-> SetSeed (index)

2)
/home/doctorant/src/InsightToolkit-4.7.0/Modules/Segmentation/RegionGrowing/include/itkConnectedThresholdImageFilter.hxx:53:1:
note:   no known conversion for argument 1 from ‘itk::Image<short int,
3u>::IndexType {aka itk::Index<3u>}’ to ‘const IndexType& {aka const
itk::Index<2u>&}’


here is my code :

#include "itkConnectedThresholdImageFilter.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkSliceBySliceImageFilter.h"
#include "iostream"

int main( int argc, char *argv[])
{
  typedef   signed short         InternalPixelType;
  typedef   unsigned char        OutputPixelType;
  const     unsigned int         Dimension = 3;
  const     int                  sliceDim =2;
  typedef itk::Image< InternalPixelType, Dimension > InternalImageType; //
input
  typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
//output

  typedef  itk::ImageFileReader< InternalImageType > ReaderType;
  typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();

  reader->SetFileName( "/home/doctorant/Téléchargements/Images/in.img" );
  writer->SetFileName( "/home/doctorant/Téléchargements/Images/out.img");


  typedef itk::SliceBySliceImageFilter< InternalImageType,OutputImageType>
SliceBySliceFilterType;

  SliceBySliceFilterType::Pointer sliceBySliceFilter =
SliceBySliceFilterType::New();

  typedef itk::ConnectedThresholdImageFilter<
SliceBySliceFilterType::InternalInputImageType,
          SliceBySliceFilterType::InternalOutputImageType >
ConnectedFilterType;
  ConnectedFilterType::Pointer connectedThreshold
=ConnectedFilterType::New();

  const InternalPixelType lowerThreshold =  -3700 ;
  const InternalPixelType upperThreshold = -600;

 connectedThreshold->SetLower(  lowerThreshold   );  // error here
 connectedThreshold->SetUpper(  upperThreshold  );  //error here
    connectedThreshold->SetReplaceValue( 255 );  // error here

    InternalImageType::IndexType  index;
    index[0] = 257;
    index[1] = 449;
    connectedThreshold->SetSeed(index);  // error here

  sliceBySliceFilter -> SetInput(reader->GetOutput());
  sliceBySliceFilter->SetFilter(connectedThreshold);
  writer->SetInput( sliceBySliceFilter->GetOutput());
  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & excep )
    {
    std::cerr << "Exception caught !" << std::endl;
    std::cerr << excep << std::endl;
    }

  return 0;
}

2015-02-06 21:59 GMT+01:00 samah bouzidi <samah.bouzidi at gmail.com>:

> hi,
>
> sincerely, I fail to understand the response of this filter, the
> algorithm succeeds to segment the region .however, in 3D, the first  slice is
> the same  used to check the segmentation in 2D, I am not getting at least for
> the first slice the region obtained in 2D.
> ps: the modified code takes into account the third dimension :
>
>
> InternalImageType::IndexType  index;
>   index[0] = 250;
>   index[1] = 239;
>   index[2]= 1;
>
>   connectedThreshold->SetSeed( index );
>
>
> any help will be appreciated.
> thanks in advance.
>
>
>
> 2015-02-04 21:24 GMT+01:00 Christopher Mullins <
> christopher.mullins at kitware.com>:
>
>> The ConnectedThresholdImageFilter example [1] might be of use.
>>
>> [1]
>> https://github.com/InsightSoftwareConsortium/ITK/blob/master/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
>>
>> On Wed, Feb 4, 2015 at 3:14 PM, samah bouzidi <samah.bouzidi at gmail.com>
>> wrote:
>>
>>> hi Matt,
>>>
>>> thank you for replying.
>>>
>>> I can't find the error in my code (a black volume result)
>>>
>>> can you please look at my code.
>>>
>>>
>>>
>>> Regards
>>> Samah
>>>
>>>
>>>
>>> 2015-02-04 20:36 GMT+01:00 Matt McCormick <matt.mccormick at kitware.com>:
>>>
>>>> Hi Samah,
>>>>
>>>> Welcome to ITK!
>>>>
>>>> For a 3D image, the third index of the seed does need to be defined.
>>>>
>>>> To apply a filter on each slice independently, use the
>>>> SliceBySliceImageFilter [1].
>>>>
>>>> HTH,
>>>> Matt
>>>>
>>>> [1]
>>>> http://www.itk.org/Doxygen/html/classitk_1_1SliceBySliceImageFilter.html
>>>>
>>>> On Wed, Feb 4, 2015 at 1:59 PM, samah bouzidi <samah.bouzidi at gmail.com>
>>>> wrote:
>>>> > hello itk users,
>>>> >
>>>> > I am a beginner ITK users. I am trying to segment a volume using
>>>> region
>>>> > growing algorithm. I am able to do it in a 2D image (dicom) but not
>>>> for a
>>>> > volume.
>>>> > 1) I saw that for 3D region growing the seed point have 3 coordinates
>>>> (x, y,
>>>> > z). In my case, z is the slice number (i am using .img format). Can I
>>>> use an
>>>> > (x,y) seed point?
>>>> > 2) I have another idea,  reading an image series  and applied the
>>>> filter for
>>>> > each image and then writing them in volume. Are there any examples (
>>>> applied
>>>> > a filter in image series) that one could help me?
>>>> >
>>>> > regards
>>>> > Samah.
>>>> >
>>>> > My source code is as follows
>>>> > ================================
>>>> > #include "itkConnectedThresholdImageFilter.h"
>>>> > #include "itkImage.h"
>>>> > #include "itkImageFileReader.h"
>>>> > #include "itkImageFileWriter.h"
>>>> >
>>>> > int main( int argc, char *argv[])
>>>> > {
>>>> >   typedef   signed short         InternalPixelType;
>>>> >   typedef   unsigned char        OutputPixelType;
>>>> >   const     unsigned int           Dimension = 3;
>>>> >   typedef itk::Image< InternalPixelType, Dimension >
>>>> InternalImageType;
>>>> >
>>>> >   typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>>>> >
>>>> >   typedef  itk::ImageFileReader< InternalImageType > ReaderType;
>>>> >   typedef  itk::ImageFileWriter<  OutputImageType  > WriterType;
>>>> >
>>>> >   ReaderType::Pointer reader = ReaderType::New();
>>>> >   WriterType::Pointer writer = WriterType::New();
>>>> >
>>>> >     reader->SetFileName(
>>>> "/home/doctorant/Téléchargements/Images/in.img" );
>>>> >     writer->SetFileName(
>>>> "/home/doctorant/Téléchargements/Images/out.img");
>>>> >
>>>> >
>>>> >   typedef itk::ConnectedThresholdImageFilter< InternalImageType,
>>>> > OutputImageType > ConnectedFilterType;
>>>> >
>>>> >   ConnectedFilterType::Pointer connectedThreshold =
>>>> > ConnectedFilterType::New();
>>>> >
>>>> >   connectedThreshold->SetInput( reader->GetOutput() );
>>>> >   writer->SetInput( connectedThreshold->GetOutput() );
>>>> >
>>>> >
>>>> >   const InternalPixelType lowerThreshold =  -1050  ;
>>>> >   const InternalPixelType upperThreshold = -600;
>>>> >
>>>> >   connectedThreshold->SetLower(  lowerThreshold  );
>>>> >   connectedThreshold->SetUpper(  upperThreshold  );
>>>> >
>>>> >   connectedThreshold->SetReplaceValue( 255 );
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >   InternalImageType::IndexType  index;
>>>> >   index[0] = 250;
>>>> >   index[1] = 239;
>>>> >
>>>> >   connectedThreshold->SetSeed( index );
>>>> >
>>>> >
>>>> >   try
>>>> >     {
>>>> >     writer->Update();
>>>> >     }
>>>> >   catch( itk::ExceptionObject & excep )
>>>> >     {
>>>> >     std::cerr << "Exception caught !" << std::endl;
>>>> >     std::cerr << excep << std::endl;
>>>> >     }
>>>> >
>>>> >   return 0;
>>>> > }
>>>> >
>>>> > _____________________________________
>>>> > 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.php
>>>> >
>>>> > 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://public.kitware.com/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.php
>>>
>>> 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://public.kitware.com/mailman/listinfo/insight-users
>>>
>>>
>>
>>
>> --
>> Christopher Mullins
>> R&D Engineer
>> Kitware Inc.,
>> 919.869.8871
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150208/962462e1/attachment.html>


More information about the Insight-users mailing list