Page MenuHomePhabricator

mitkExtractImageFilter shifts the coronal plane for one slice
Closed, WontfixPublic


When using the mitkExtractImageFilter to extract a 2D slice out of an image volume for the coronal perspective then the geometry of the obtained slice is shift for one pixel towards the origin.

E.g. if you draw a contour in any coronal slice and the you use the mitkExtractImageFilter to get the slice and extract the contour, then the extracted contour is shifted for one pixel.

See also the screenshot

Event Timeline

The problem is located in the mitk::ExtractImageFilter.
The filter takes a 3D image as input and produces a 2D image output.
The geometry of the 2D output image is wrong.

The error happens in mitkExtractImageFilter.cpp line 96 - 100

A new PlaneGeometry is created for the 2D image based upon the 3D input image.

in line 97
"planeGeometry->InitializeStandardPlane( inputImageGeometry, orientation, (ScalarType)m_SliceIndex, true, false );"
is called

which calls another InitializeStandardPlane method:
" InitializeStandardPlane( width, height,

planeorientation, zPosition, frontside, rotated ); "

In that function (we are now in mitkPlaneGeometry.cpp line 150)
the vectors for the geometry: origin, rightDV and bottomDV are filled.

subsequently in line 283 the function
" this->SetMatrixByVectors(

rightDV, bottomDV,
  .get_column(normalDirection).magnitude() "

is called.

Here the matrix for the geometry is calculated out of the vectors. However that calculation gives you the wrong result.

We are sill trying to figure out why. The calculation itself seems right, but the input values might be in the wrong order ? Strangely the error only occurs when extracting a frontal plane.

We now fixed the issue with the shifted surfaces. The problem was that at the initialization of the current plane. If we are dealing with an image geometry 0.5 was subtracted from the plane's origin. We changed that the following:

If our plane lies in the x-plane, then 0.5 is no longer subtracted from the origin's x-component.

The problem is now that the contours are not drawn into the plane correctly any more. But we are working on it.

There is another impact of this bug:

  1. Create a new segmentation
  2. Draw contours in several (not subsequent) slices of the coronal orientation
  3. Navigate through the slices

-> You can see that the interpolated contour is shifted for one slice

With our fix of this bug the interpolated contour if displayed in the correct slice but shifted for one pixel in two directions (depending on the orientation).

We will look after that during the next bugsquashing.

Note: If you accept the interpolation the contours are written correctly into the segmentation. So only the FeedBackContour of the interpolation is displayed wrong.

I tried to figure out the reason for this displacement:

The interpolation happens as follows:

  1. Extract the current slice (which must be interpolated) and the neighbouring

segmented sliced.

  1. Interpolate the new segmentation for the current slice out of its neighbours.

(It is saved as helper object in the datamanager)

  1. When clicking accept write the interpolated slice into the segmentation.

The problem seems to be that the interpolated slice's origin is shift for 0.5
whereas the one of the original segmentation is not.
That's is why the interpolation is displayed in a wrong way.

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.

kislinsk added a project: Auto-closed.
kislinsk added a subscriber: kislinsk.

Hi there! 🙂

This task was auto-closed according to our Task Lifecycle Management.
Please follow this link for more information and don't forget that you are encouraged to reasonable re-open tasks to revive them. 🚑

Best wishes,
The MITK devs