Page MenuHomePhabricator

image cropper crashes with 2d images
Closed, ResolvedPublic


  • Load Pic3D
  • Open Image Crop
  • Click "New Bounding Box" - "Cuboid"
  • Use Mouse interacton to make bounding box quite small. then the bug is better visible.
  • "Crop"

In the resulting image, watch..

  • coronal slice number 0 - its all grey
  • axial slice number 0 - its all grey as well

Imagecropper is always producing these borders.

Event Timeline

An extra slice is produced, which is initialized with the value "0". This is "grey" in CT images.

question is: why is an extra slice produced?

Apparently this is done un purpose:

When cropping, sometimes you might want to add a border (perform a padding). E.g. when you crop a segmentation and create a model out of it, the surface is not closed on the sides, where the segmentation touches the image border.

1st: This padding should be on all sides!

2nd: That padding is not always wanted, so it should be a checkable extra. Add a checkbox to bundle maybe.

Correction: Padding is not really done on purpose.

In general, the structure of the whole thing is not good.

Maybe recreationg using the itk::ImageCropFilter
is possible

Fixed crash with 2d images:
instead of altering the image geometry , we copied the origin of the input image geometry and shifted it by half a pixel, before setting it as origin for the bounding object.

Still to do:

  • find out why gray slices are produced

Current behavior:

  • BoundingObjectCutter gets CroppingObject and Image as input. Then it is updated
  • BoundingObjectCutter creates m_InputRequestedRegion
  • BoundingObjectCutter calls "Cut" Function:
  • cutFunction:
    • Create Iterator over image within the m_InputRequestedRegion
    • while incrementing iterator, transform pixel into world coordinates with inputImage->Getgeometry() and check if that world point isInside boundingObject->GetGeometry(). If so, copy value, if not, assing outsidepixelvalue.

New remote branch pushed: bug-14173-GraySlicesRemovalAndSpacingFix

Just to say that I have the same problem with 2D images. When I load a 2D image (png or jpg), create a bounding object and cut the image with a BoundingObjectCutter, it fails when I call :
mitk::BoundingObjectCutter::Pointer filter = mitk::BoundingObjectCutter::New();
filter->Set some stuff
In mitkBoundingObjectCutter.cpp in GenerateInputRequestedRegion() on line
delete [] dimensions;

The same code works perfectly with 3D images.

I get build errors when I try to build the remote branch. Furthermore the branch contains some MITK_INFOs which should be removed and some code which is commented out. Talk already with christian about that.

current state:
problem with gray slices still persists.

but last commit fixes crash for image spacings <2,
and also for 2d objects a waning is now displayed and interaction aborted
-> no crash.

how to handle 2d objects has to be discussed in future.

I tested the branch on my Mac and noticed two things:

  • The warning label does not disappear if a 3d or 4d image is selected after a 2d image was selected
  • Currently the warning label's text is rather long. I think "The image cropper cannot handle 2D images" would be sufficient

[ead4de]: Merge branch 'bug-14173-GraySlicesRemovalAndSpacingFix'

Merged commits:

2013-03-21 10:11:47 Christian Weber [a95966]
shorten warning message,
make label invisible when switched back to 3d image

2013-03-20 14:10:34 Christian Weber [652a4a]
show warning when 2d object is selected,
and disable widget

2013-03-20 12:47:21 Christian Weber [0a7e14]
do not add interactor for 2d images at all, to prevent crash ..

2013-03-20 12:38:53 Christian Weber [2222fb]
Added check for 2D images

2013-03-20 10:57:00 Christian Weber [cf40c9]
remove MITK_INFOs , revert to fixing crash with 2d images only

2013-02-06 17:42:33 Christian Weber [58678c]
Fixed spacing <2 by changing Geometry update, Gray slices still work in progress


It looks like the 2d image crash is fixed, but the grey slice issue still needs discussion. Please split this bug in two and close the one related to the 2d image cropping crash.

Closing this bug for crashing on 2d images.

Creating gray slices while cropping is now moved to T15127.