Page MenuHomePhabricator

Offset-Bug in ImageStatisticsCalculator
Closed, ResolvedPublic

Description

When using mitkImageStatisticsCalculator with a PlanarFigure to define a ROI, there is a severe offset bug.
If the right border of a pixel is included in the ROI, it is completely used for masking.

That means if I have a ROI that encircles one pixel but does not cross the right border to the next pixel I have no statistics.

If this ROI contains 99% of the pixel on the right of the first pixel, this second pixel will NOT be considered in the statistics.

If this ROI contains 1% of the pixel on the left side (only the righternmost 1%), this pixel is completely considered by the statistics.

The most accurate way to fix this would be to make the statistics calculation work correctly on sub-pixel level.
However, this would mean immense workload and will not be done in the near future.

The quick-fix / improvement would be to use a pixel for statistics calculation as soon as the planarFigure crosses the center of the pixel. This would fix the false behaviour mentioned above.

Event Timeline

engelm added a subscriber: engelm.

Screenshot showing the false behaviour

screenshot.png (1×1 px, 162 KB)

[d57e8f]: Merge branch 'bug-8078-imagestatistics-planarfigure-offset'

  • bug-807

Merged commits:

2011-05-10 16:22:43 Markus Engel [15f52e]
removing coordinate-correction to fix offset bug for planarfigure masking

Removed two lines of code in mitkStatisticsCalculator that were responsible for the 0.5 pixel offset in the creation of a masking image using a PlanarFigure.

Statistics calculation works as expected now...

Needs to be reopened for real fix of problem

[4196b3]: Merge branch 'bug-8078-imagestatistics-planarfigure-offset'

  • bug-807

Merged commits:

2011-05-12 15:39:36 Markus Engel [1cede8]
introduced new pipeline to create imagemask from PlanarFigure;

The old pipeline has been replaced by a simple filter vtkLassoStencilSource that
creates a vtkImageStencil from a polygon. This new approach works correctly
for all kinds of intersections of pixels.
The two new classes will be released in VTK 5.8, that why we have them here
temporarily.


2011-05-12 15:28:24 Daniel Maleike [fa3a1d]
Build a switch to use two VTK 5.8 classes even when using VTK 5.6 (with VTK 5.8, use the real VTK classes)


2011-05-12 15:17:31 Markus Engel [92bad7]
adding classes from VKT 5.8 needed for statistics calculation

When intersecting pixels at an off angle the behaviour of the existing filter-pipeline was rather unpredictable. Some pixels were considered while other pixels that were intersected in the same way were not.

VTK 5.8 will introduce a new class vtkLassoStencilSource that creates a vtkImageStencil from the points of a polygon (exactly what we want).

I copied the two classes that were needed ( vtkLassoStencilSource & vtkImageStencilRaster ) to mitkExt and introduced '#ifdef's to make sure the real vtk classes are used as soon as vtk 5.8 is used.

The resulting pipeline is shorter, the readability is improved and the results are a lot more accurate (has been verified by a Unit-test that is developed under T8077)

[b9c40c]: Merge branch 'bug-8078-imagestatistics-planarfigure-offset'

  • bug-807

Merged commits:

2011-05-13 13:55:53 Markus Engel [7aef88]
removed commented code

Branch is everywhere we need it, can be closed...