View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010398ITKpublic2010-03-09 23:392010-10-25 16:17
ReporterRohit Saboo 
Assigned ToGaetan Lehmann 
PrioritynormalSeverityminorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product VersionITK-3-16 
Target VersionFixed in Version 
Summary0010398: At least one of ErodeObjectMorphologyImageFilter and DilateObjectMorphologyImageFilter not behaving as expected
DescriptionA closed image should contain the original image. However the result of applying DilateObjectMorphologyImageFilter followed by ErodeObjectMorphologyImageFilter results in an image which is shrunk compared to the original image.

This error is not observed when one uses BinaryDilateImageFilter and BinaryErodeImageFilter

I've uploaded a sample file and attached the code for a program that will read in an input file, perform the close, and save the result back. You can comment out and uncomment the appropriate lines to change the filter being used.

You may call it with
close_filter mandible.mha closed_mandible.mha 3
The error will be most clearly visible near axial slices 24 and 25 of the closed image.
Additional Information#include <iostream>

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkBinaryBallStructuringElement.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkDilateObjectMorphologyImageFilter.h"
#include "itkErodeObjectMorphologyImageFilter.h"
#include "itkBinaryDilateImageFilter.h"
#include "itkBinaryErodeImageFilter.h"

using namespace std;

int main(int argc, char* argv[])
{
    typedef unsigned short Pixel;
    typedef itk::Image<Pixel,3> ImageType;

    // Binary Morphology filters
    typedef itk::BinaryBallStructuringElement< Pixel, 3 > Kernel;
    typedef itk::DilateObjectMorphologyImageFilter<ImageType,ImageType,Kernel> Dilater;
    //typedef itk::BinaryDilateImageFilter<ImageType,ImageType,Kernel> Dilater;
    typedef itk::ErodeObjectMorphologyImageFilter<ImageType,ImageType,Kernel> Eroder;
    //typedef itk::BinaryErodeImageFilter<ImageType,ImageType,Kernel> Eroder;

    typedef itk::ImageFileReader<ImageType> Reader;
    typedef itk::ImageFileWriter<ImageType> Writer;

    if(argc != 4) {
        cerr << "Incorrect number of arguments" << endl
             << "Usage: close_filter <infile> <outfile> <radius (in voxels)>" << endl;
        return 1;
    }
    const char* infile = argv[1];
    const char* outfile = argv[2];
    const int radius = atoi(argv[3]);

    try {
        // Setup input
        cout << "Reading input file <" << infile << "> ... " << flush;
        Reader::Pointer reader = Reader::New();
        reader->SetFileName(infile);
        reader->Update();
        cout << "done" << endl;

        // Create the structuring element:
        cout << "Creating structuring element ... " << flush;
        Kernel ball;
        ball.SetRadius(radius);
        ball.CreateStructuringElement();
        cout << "done" << endl;

        // Now do the close
        cout << "Dilating ... " << flush;
        Dilater::Pointer closeDilate = Dilater::New();
        closeDilate->SetObjectValue(1);
        //closeDilate->SetForegroundValue(1);
        closeDilate->SetKernel(ball);
        closeDilate->SetInput(reader->GetOutput());
        closeDilate->Update();
        cout << "done" << endl;

        cout << "Eroding ... " << flush;
        Eroder::Pointer closeErode = Eroder::New();
        closeErode->SetObjectValue(1);
        //closeErode->SetForegroundValue(1);
        closeErode->SetKernel(ball);
        closeErode->SetInput(closeDilate->GetOutput());
        closeErode->Update();
        cout << "done" << endl;

        // Now write the output
        cout << "Writing output file <" << outfile << "> ... " << flush;
        Writer::Pointer writer = Writer::New();
        writer->SetFileName(outfile);
        writer->SetInput(closeErode->GetOutput());
        writer->Update();
        cout << "done" << endl;
    }
    catch (itk::ExceptionObject & exc) {
        // Show the error
        cerr << "Error processing image: " << exc.GetDescription () << endl;
    }

    return 0;
}
TagsNo tags attached.
Resolution Date
Sprint
Sprint Status
Attached Files? file icon mandible.mha [^] (58,329 bytes) 2010-03-09 23:39

 Relationships

  Notes
There are no notes attached to this issue.

 Issue History
Date Modified Username Field Change
2010-03-09 23:39 Rohit Saboo New Issue
2010-03-09 23:39 Rohit Saboo File Added: mandible.mha
2010-10-25 16:17 Gaetan Lehmann Status new => assigned
2010-10-25 16:17 Gaetan Lehmann Assigned To => Gaetan Lehmann


Copyright © 2000 - 2018 MantisBT Team