They use morphological grayscale openings with a combination of spheres and 3D lines structuring elements. The lines structuring elements are oriented in several directions.
I would like to know how to make 3D oriented line structuring elements with ITK.
There is the itkFlatStructuringElement, but I don’t know if the Box function is the one I’m looking for. The documentation is a bit short and the examples on the wiki have been removed with the near ITK 5.0 release.
I also found the LineIterator to draw custom lines using two points. But the result probably won’t be usable by GrayscaleMorphologicalOpeningFilter…
Yes, you are on the right track. Depending on what you want, AddLine, FromImage, or Polygon are likely closer than Box for your application. The itk::FlatStructuringElement source code and the ITK Software Guide have more details or a higher level overview, respectively.
When I have to create a custom structuring element, I usually go back to the Neighborhood base class.
For a small example, you can see this post I made a while back on the same topic.
@matt.mccormick
I need your input once more because I’m doing something wrong here…
// A bit of typedef context
typename TInputImage::Pointer input = TInputImage::New();
input->Graft( const_cast<TInputImage*>( this->GetInput() ));
using LineSeType = FlatStructuringElement<3>;
using OpeningLineFilterType =GrayscaleMorphologicalOpeningImageFilter
<TInputImage,TInputImage,LineSeType>;
auto openingLineFilter = OpeningLineFilterType::New();
openingLineFilter->SetInput( input );
// Problematic code portion
LineSeType lineSe;
lineSeImage = line3D(s,v[n],1.0,1.0,1.0);
// Viewing structuring element image for debug purpose
auto castFilter = CastImageFilter<itk::Image<bool,3>,itk::Image<int,3>>::New();
castFilter->SetInput(lineSeImage);
itk::ViewImage<itk::Image<int,3>>::View(castFilter->GetOutput() ); openingLineFilter->SetKernel( lineSe.FromImage(lineSeImage) );
openingLineFilter->Update();
auto imLine = openingLineFilter->GetOutput();
// viewing Opening image for debug purpose
itk::ViewImage::View(imLine);
From my previous post the first 3 steps are doing great. I managed to create a 3D boolean image (odd dimensions as the documentation requires) with the structuring element. As you can see in the picture below.