[ITK] [ITK-users] Anti-alias filter

Tobias Gass gass at vision.ee.ethz.ch
Tue Aug 12 10:10:34 EDT 2014


Yes, this does result in the same problems as before.


2014-08-12 15:06 GMT+02:00 Bill Lorensen <bill.lorensen at gmail.com>:

> Have you tried:
> UseImageSpacingOn();
>
>
> On Tue, Aug 12, 2014 at 8:47 AM, Tobias Gass <gass at vision.ee.ethz.ch>
> wrote:
> > Further update: when manually increasing the spacing of the input image
> > (without resampling, thus not changing the size), the filter works well.
> > This probably indicates numerical instability depending on image spacing
> > somewhere in the code, which would probably be great if it could be
> fixed.
> >
> > Best,
> > Tobias
> >
> >
> > 2014-08-12 14:33 GMT+02:00 Tobias Gass <gass at vision.ee.ethz.ch>:
> >
> >> Update: meanwhile I also tried cropping the image to investigate the
> >> impact of the overall size (#voxels) of the image. It appears to not
> have an
> >> effect, the same artifacts occur when processing a significantly smaller
> >> region (1/2 size).
> >>
> >>
> >> 2014-08-12 10:44 GMT+02:00 Tobias Gass <gass at vision.ee.ethz.ch>:
> >>
> >>> Hi,
> >>>
> >>> changing the PixelType did not yield any change. However, I did some
> >>> further tests which seem to point at image spacing or total size to be
> the
> >>> culprit. My original image is fairly high-res, with 0.25mm in-plane
> >>> resolution and 0.75mm slice thickness and 512x512x409 voxel size. I
> tried
> >>> resampling the image to different isotropic resolutions (0.25, 0.3,
> 0.34,
> >>> 0.35, 0.4, 0.5, 0.75, 1)mm isotropic spacing. For all spacings down to
> >>> 0.35mm, the AA filter converged nicely and the output looks as I'd
> expect
> >>> it. Lower than 0.35mm spacing, and it fails in the way I described
> (from
> >>> this spacing on the #vox is equal or greater than the #voxels in my
> original
> >>> image).
> >>>
> >>> Any idea what might cause this, or what to further investigate?
> >>>
> >>> Thanks,
> >>> Tobias
> >>>
> >>>
> >>> 2014-08-11 22:17 GMT+02:00 Bill Lorensen <bill.lorensen at gmail.com>:
> >>>
> >>>> Paraview should do the right thing.
> >>>>
> >>>> On Mon, Aug 11, 2014 at 3:38 PM, Tobias Gass <gass at vision.ee.ethz.ch>
> >>>> wrote:
> >>>> > I will try that tomorrow morning (living in GMT+1). I used paraview
> to
> >>>> > extract the isosurface, but also looked at the output of the
> AA-filter
> >>>> > directly (which looked fuzzy). I can also post an image of that
> >>>> > tomorrow.
> >>>> >
> >>>> > Thanks for your help!
> >>>> > Tobias
> >>>> >
> >>>> >
> >>>> > 2014-08-11 21:22 GMT+02:00 Bill Lorensen <bill.lorensen at gmail.com>:
> >>>> >
> >>>> >> How are you extracting the final isosurface?
> >>>> >>
> >>>> >> On Mon, Aug 11, 2014 at 3:22 PM, Bill Lorensen
> >>>> >> <bill.lorensen at gmail.com>
> >>>> >> wrote:
> >>>> >> > If you change
> >>>> >> >  typedef  short PixelType;
> >>>> >> > to
> >>>> >> >  typedef  double PixelType;
> >>>> >> >
> >>>> >> > do the results change.
> >>>> >> >
> >>>> >> >
> >>>> >> > On Mon, Aug 11, 2014 at 2:47 PM, Tobias Gass
> >>>> >> > <gass at vision.ee.ethz.ch>
> >>>> >> > wrote:
> >>>> >> >>
> >>>> >> >>> Can you post your code. The results do not look correct.
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> Sure. The {write,read}Image functions are just convenient
> wrappers
> >>>> >> >> for
> >>>> >> >> the
> >>>> >> >> respective ITK tools.
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> #include <stdio.h>
> >>>> >> >>
> >>>> >> >> #include <iostream>
> >>>> >> >>
> >>>> >> >> #include "argstream.h"
> >>>> >> >>
> >>>> >> >> #include "ImageUtils.h"
> >>>> >> >>
> >>>> >> >> #include "itkAntiAliasBinaryImageFilter.h"
> >>>> >> >>
> >>>> >> >> using namespace std;
> >>>> >> >>
> >>>> >> >> using namespace itk;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> int main(int argc, char ** argv)
> >>>> >> >>
> >>>> >> >> {
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
> >>>> >> >>
> >>>> >> >>     typedef  short PixelType;
> >>>> >> >>
> >>>> >> >>     typedef double OutputPixelType;
> >>>> >> >>
> >>>> >> >>     const unsigned int D=3;
> >>>> >> >>
> >>>> >> >>     typedef Image<PixelType,D> ImageType;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     typedef ImageType::Pointer ImagePointerType;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     typedef Image<OutputPixelType,D> OutputImageType;
> >>>> >> >>
> >>>> >> >>     typedef OutputImageType::Pointer OutputImagePointerType;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     argstream * as=new argstream(argc,argv);
> >>>> >> >>
> >>>> >> >>     string inFile, outFile;
> >>>> >> >>
> >>>> >> >>     double thresh=0.0;
> >>>> >> >>
> >>>> >> >>     (*as) >> parameter ("in", inFile, " filename...", true);
> >>>> >> >>
> >>>> >> >>     (*as) >> parameter ("out", outFile, " filename...", true);
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     (*as) >> help();
> >>>> >> >>
> >>>> >> >>     as->defaultErrorHandling();
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     ImagePointerType img =
> >>>> >> >> ImageUtils<ImageType>::readImage(inFile);
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     typedef itk::AntiAliasBinaryImageFilter <ImageType,
> >>>> >> >> OutputImageType>
> >>>> >> >>
> >>>> >> >>         AntiAliasBinaryImageFilterType;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     AntiAliasBinaryImageFilterType::Pointer antiAliasFilter
> >>>> >> >>
> >>>> >> >>         = AntiAliasBinaryImageFilterType::New ();
> >>>> >> >>
> >>>> >> >>     antiAliasFilter->SetInput(img);
> >>>> >> >>
> >>>> >> >>     antiAliasFilter->SetNumberOfIterations(5);
> >>>> >> >>
> >>>> >> >>     antiAliasFilter->SetMaximumRMSError(0.02);
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     antiAliasFilter->Update();
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   // For increased code coverage.  Does nothing.
> >>>> >> >>
> >>>> >> >>   antiAliasFilter->GetMaximumRMSError();
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   antiAliasFilter->Update();
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   std::cout << "Maximum RMS change value threshold was: 0.02 "
> <<
> >>>> >> >> std::endl;
> >>>> >> >>
> >>>> >> >>   std::cout << "Last RMS change value was: " <<
> >>>> >> >> antiAliasFilter->GetRMSChange() << std::endl;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   std::cout<< antiAliasFilter->GetElapsedIterations() <<endl;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>   std::cout<<antiAliasFilter->GetLowerBinaryValue()<<" "<<
> >>>> >> >> antiAliasFilter->GetUpperBinaryValue()<<std::endl;
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     OutputImagePointerType out=antiAliasFilter->GetOutput();
> >>>> >> >>
> >>>> >> >>
> >>>> >> >>     ImageUtils<OutputImageType>::writeImage(outFile,out);
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> return 1;
> >>>> >> >>
> >>>> >> >> }
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> I tried different values for maxIter (1,2,3,4,5,10,100,1000) and
> >>>> >> >> maxRMSError
> >>>> >> >> (0.02 0.07 0.08 0.8), and the best visual results are achieved
> >>>> >> >> after
> >>>> >> >> one
> >>>> >> >> iteration where RMSE changes by about 0.08. This increases for
> all
> >>>> >> >> following
> >>>> >> >> iterations, which have an RMSE-change of about 0.25 for all
> number
> >>>> >> >> of
> >>>> >> >> iterations tested. All this is using ITK 4.5 pulled from the GIT
> >>>> >> >> repository
> >>>> >> >> a while ago, running on an intel i7 on Debian.
> >>>> >> >>
> >>>> >> >> Thanks a lot!
> >>>> >> >> Tobias
> >>>> >> >>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> On Mon, Aug 11, 2014 at 12:18 PM, Tobias Gass
> >>>> >> >>> <gass at vision.ee.ethz.ch>
> >>>> >> >>> wrote:
> >>>> >> >>> > Dear all,
> >>>> >> >>> >
> >>>> >> >>> > I'm having problems using the anti-alias filter, which I want
> >>>> >> >>> > to use
> >>>> >> >>> > in
> >>>> >> >>> > order to smooth a binary segmentation volume. I'm using
> >>>> >> >>> > essentially
> >>>> >> >>> > the
> >>>> >> >>> > example code from the repository, which for my input file
> seems
> >>>> >> >>> > to
> >>>> >> >>> > start
> >>>> >> >>> > oscillating after 2 iterations, leading to weird 'pointy'
> >>>> >> >>> > artifacts
> >>>> >> >>> > on
> >>>> >> >>> > the
> >>>> >> >>> > surface as can be seen from the attached screenshot (AA
> filter
> >>>> >> >>> > output is
> >>>> >> >>> > on
> >>>> >> >>> > the left, input on the right).
> >>>> >> >>> >
> >>>> >> >>> > Is there any parameter to set/implement which could improve
> the
> >>>> >> >>> > behavior
> >>>> >> >>> > of
> >>>> >> >>> > this filter? I'm assuming that my input is reasonable, or is
> >>>> >> >>> > this
> >>>> >> >>> > something
> >>>> >> >>> > the filter is expected to have problems with? It is notable
> >>>> >> >>> > that
> >>>> >> >>> > such
> >>>> >> >>> > errors
> >>>> >> >>> > seem to mainly appear in 'flat' regions of the volume, and
> are
> >>>> >> >>> > not
> >>>> >> >>> > apparent
> >>>> >> >>> > in the curved shaft of the bone.
> >>>> >> >>> >
> >>>> >> >>> > Any help, or pointers to further resources are appreciated,
> >>>> >> >>> > thanks,
> >>>> >> >>> > Tobias
> >>>> >> >>> >
> >>>> >> >>> > _____________________________________
> >>>> >> >>> > 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
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> --
> >>>> >> >>> Unpaid intern in BillsBasement at noware dot com
> >>>> >> >>
> >>>> >> >>
> >>>> >> >
> >>>> >> >
> >>>> >> >
> >>>> >> > --
> >>>> >> > Unpaid intern in BillsBasement at noware dot com
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Unpaid intern in BillsBasement at noware dot com
> >>>> >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Unpaid intern in BillsBasement at noware dot com
> >>>> _____________________________________
> >>>> 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
> >>>
> >>>
> >>
> >
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140812/9091ed93/attachment-0002.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