[ITK] [ITK-users] Binary Contour Detection for 3D Image using ITK - Thickness -

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Tue Feb 7 08:52:41 EST 2017


Hello,

I believe that the BinaryCountourImageFilter operates in voxel space so the pixel spacing would not have an effect.

I think you are using the wrong metric to determine if the contour is “1 pixel thick”. You need to remember that you are dealing with a 3D space where the contour is a 2-manifold in the 3-d space. That is to say your “contour" has 2 dimensions of thickness and 1 dimension that only 1 pixel thick. If you have planar edges this can result in large areas that are solid contours. Please look at the results of “unexpected” contours in the xy-plane xz-plane _and_ yz_ plane to understand the geometry.

Alternatively, if the requirement is to have each slice look like a 1-d contour you can run contour filter in the SliceBySliceImageFitler[1]. However, this will omit the edges that are between slices.

HTH,
Brad

[1] https://itk.org/Doxygen/html/classitk_1_1SliceBySliceImageFilter.html



On Feb 7, 2017, at 8:33 AM, Abdelkhalek Bakkari <bakkari.abdelkhalek at hotmail.fr<mailto:bakkari.abdelkhalek at hotmail.fr>> wrote:

I am sorry but i did not find the SetUsePixelSpacingOff. Could you explain to me the way of using it. Also, what actually does it mean to turn off the spacing between slices and slice pixel and how is it related to contour generation .
Kind regards,

Sent from my iPhone

On 7 Feb 2017, at 13:46, Dženan Zukić <dzenanz at gmail.com<mailto:dzenanz at gmail.com>> wrote:

Try SetUsePixelSpacingOff.

On Feb 7, 2017 06:30, "Abdelkhalek Bakkari" <bakkari.abdelkhalek at hotmail.fr<mailto:bakkari.abdelkhalek at hotmail.fr>> wrote:

Dear ITK users,


After using the BinaryFillHoleFilter for a 3D Dicom image (see attached), I adopted the BinaryContourImageFilter in order to obtain the contour of the image.  However, the thikness of the contour is very big. My goal is to obtain 1 pixel of thickness.


The fragment of my code is :


------------------------------------------------------

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkCastImageFilter.h"
#include "itkCannyEdgeDetectionImageFilter.h"
#include <itkBinaryContourImageFilter.h>
#include <vtkImageData.h>
#include <vtkExtractVOI.h>
#include <itkLabelToRGBImageFilter.h>
#include <itkImageToVTKImageFilter.h>
#include <itkVTKImageToImageFilter.h>
#include <vtkSmartPointer.h>

int main(int argc, char **argv)
{



       const unsigned int     Dimension = 3;
typedef unsigned char InputPixelType;
typedef unsigned char  OutputPixelType;

typedef itk::Image<InputPixelType, Dimension>  InputImageType;
typedef itk::Image<OutputPixelType, Dimension> OutputImageType;

typedef itk::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName("BinaryFillHoleImage.mha");
reader->Update();

//Slice by Slice Binary Contour
// Binary Contour Filter
typedef itk::BinaryContourImageFilter <InputImageType, InputImageType > binaryContourImageFilterType;

binaryContourImageFilterType::Pointer binaryContourFilter = binaryContourImageFilterType::New ();
binaryContourFilter->SetInput(reader->GetOutput());
binaryContourFilter->SetFullyConnected(1); // true makes thicker contours
binaryContourFilter->SetBackgroundValue(0);
binaryContourFilter->SetForegroundValue(255); // the value of your binary mask
binaryContourFilter->Update();

typedef itk::RescaleIntensityImageFilter< InputImageType, InputImageType > RescaleType;
RescaleType::Pointer rescaler = RescaleType::New();
rescaler->SetInput( binaryContourFilter->GetOutput() );
rescaler->SetOutputMinimum( 0 );
rescaler->SetOutputMaximum( 255 );

typedef itk::CastImageFilter< InputImageType, OutputImageType > FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput( rescaler->GetOutput() );

// Save the contour
{
typedef itk::ImageFileWriter<OutputImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("Cannybinarycontour.mha");
writer->SetInput(filter->GetOutput());

try{
writer->Update();
}
catch(itk::ExceptionObject &e)
{
std::cerr << e << std::endl;
}
}

    return EXIT_SUCCESS;
}




------------------------------------------------------


Thank you in advance.



Best regards,


Abdelkhalek Bakkari
Ph.D candidate in Computer Science
Institute of Applied Computer Science
Lodz University of Technology, Poland


_____________________________________
Powered by www.kitware.com<http://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
_______________________________________________
Community mailing list
Community at itk.org
http://public.kitware.com/mailman/listinfo/community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170207/93c48c0b/attachment-0001.html>
-------------- next part --------------
_____________________________________
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


More information about the Community mailing list