Page MenuHomePhabricator

mitk::ExtractSliceFilter::GenerateData doesn't handle data that is out of volume well
Closed, ResolvedPublic

Description

In line 335 of mitkExtractSliceFilter.cpp, the method "GetClippedPlaneBounds" returns a value of false if the geometry is too far out of bounds.

This value is not checked, and produces crashes in Rendering when xMin, xMax, yMin, yMax are calucated using garbage data.

I have a proposal to fix the problem at line 335.

if (this->GetClippedPlaneBounds( m_WorldGeometry->GetReferenceGeometry(), planeGeometry, sliceBounds ) == false)
{
    // If no reference geometry is available, we also don't know about the
    // maximum plane size;
    xMin = yMin = 0;
    xMax = static_cast< int >( extent[0]);
    yMax = static_cast< int >( extent[1]);
} else
{
    // Calculate output extent (integer values)
    xMin = static_cast< int >( sliceBounds[0] / m_OutPutSpacing[0] + 0.5 );
    xMax = static_cast< int >( sliceBounds[1] / m_OutPutSpacing[0] + 0.5 );
    yMin = static_cast< int >( sliceBounds[2] / m_OutPutSpacing[1] + 0.5 );
    yMax = static_cast< int >( sliceBounds[3] / m_OutPutSpacing[1] + 0.5 );
}

Event Timeline

Tobias, I think you were the one implementing most of this filter. Could you check if the logic is ok? I developed this fix with Wendell and also pushed it in a cleaned up shape into bug-13321-extract-slice-outside-of-volume.

(In reply to comment #1)

Tobias, I think you were the one implementing most of this filter. Could you
check if the logic is ok? I developed this fix with Wendell and also pushed
it in a cleaned up shape into bug-13321-extract-slice-outside-of-volume.

Also it would be good if you or somebody (during bug squashing) could enhance the unit test with an "out of volume" case. I don't feel comfortable to change a test longer than 1000 lines (needs refactoring), otherwise I would quickly do it myself.

The fix seems to be ok so far. Using a default extent would be the solution i prefer too.

I will have a look at the test next bug squashing.

I had a closer look to the proposed fix. Looks ok.

[afa09a]: Merge branch 'bug-13321-extract-slice-outside-of-volume'

Merged commits:

2012-10-02 00:57:30 Daniel Maleike [d2e5a6]
Use calculated plane extent ONLY if validly calculated

Thanks Tobias for checking, then I'll integrate the branch (late because I was on vacation and thought the assignee would do it).

All tests pass locally, images are rendered as usually.