[ITK-users] Binary Contour Detection for 3D Image using ITK - Thickness -
Abdelkhalek Bakkari
bakkari.abdelkhalek at hotmail.fr
Tue Feb 7 08:33:41 EST 2017
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20170207/f8afac39/attachment-0001.html>
More information about the Insight-users
mailing list