question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transform-CropToMask: crops image to the extremes of a bounding box about a given mask

See original GitHub issue

🚀 Feature

Transform that crops given image to the extremes of a bounding box about a given mask.

Motivation

Such a transform is really useful in lung imaging for example, where we cut out the rest of the chest CT (which can include the unwanted abdomen) to crop to a lung segmentation that is fairly easy to acquire.

Pitch

A transform CropToMask that takes mask_name and a padding variable and crops an input ScalarImage to the bounding box about mask_name with padding to the crop bounding box.

If the padding value exceeds the limits of the ScalarImage then pad the output as provided by padding_mode.

Alternatives

As suggested by @fepegar could also make this an implementation of CropOrPad that takes target_shape=None and mask_name.

Additional context

Currently, I implement this by preprocessing my data separately. Example for lung mask in chest CT.

Screenshot

Screenshot_3

The CT images provided from QIN LUNG CT (https://wiki.cancerimagingarchive.net/display/Public/QIN+LUNG+CT#b8d88cce4fd14620bef4e5e35ec3d589) under Creative Commons Attribution 3.0 Unported License (https://creativecommons.org/licenses/by/3.0/). The citations are:

  • Goldgof, Dmitry, Hall, Lawrence, Hawkins, Samuel, Schabath, Matthew, Stringfield, Olya, Garcia, Alberto, … Gillies, Robert. (2015). Data From QIN_LUNG_CT. The Cancer Imaging Archive. http://doi.org/10.7937/K9/TCIA.2015.NPGZYZBZ
  • Jayashree Kalpathy-Cramer, Sandy Napel, Dmitry Goldgof, Binsheng Zhao. QIN multi-site collection of Lung CT data with Nodule Segmentations. http://dx.doi.org/10.7937/K9/TCIA.2015.1BUVFJR7
  • Clark K, Vendt B, Smith K, Freymann J, Kirby J, Koppel P, Moore S, Phillips S, Maffitt D, Pringle M, Tarbox L, Prior F. The Cancer Imaging Archive (TCIA): Maintaining and Operating a Public Information Repository, Journal of Digital Imaging, Volume 26, Number 6, December, 2013, pp 1045-1057. (https://doi.org/10.1007/s10278-013-9622-7)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ashkanpakzadcommented, Sep 29, 2021

Yes, very good point, thank you. I’ll park it here for the future maybe 😃

0reactions
fepegarcommented, Oct 1, 2021

Reopening after more interest has been shown on #677.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I crop an image based on custom mask
You can try to find the bounding box around your predicted mask and then crop your image using the detected bounding box.
Read more >
How to use Albumentations for detection tasks if you need ...
It ensures that the cropped part will contain all bounding boxes from the original image. Then the transform rescales the crop to height...
Read more >
tf.image.crop_to_bounding_box | TensorFlow v2.11.0
Crops an image to a specified bounding box. ... This op cuts a rectangular bounding box out of image . The top-left corner...
Read more >
Cropping bounding box in separate image · Issue #803
Hello, I need help to edit detect.py for crop bounding boxes (detected object) as separate image. and save them in specific directory.
Read more >
arXiv:2104.06404v2 [cs.CV] 15 Jun 2022
Our experiments show that a bounding box and 10 annotated points per instance are approximately 5 times faster to collect than the standard ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found