Home > Net >  How to remove white borders around X-ray image with OpenCV Python
How to remove white borders around X-ray image with OpenCV Python

Time:07-26

I have thousands of X-ray images of the left hand. All of these images have thin white borders surrounding them.

I want to create a function (OpenCV/numpy) that will allow me to just auto remove/crop these thin white borders out or replace them with black/gray color.

enter image description here

enter image description here

First image is the original image, second image is the output with white borders removed. Is this even possible?

Note: For some images, the white borders aren't always surrounding the image, instead there can be white bars on the sides of the image --> enter image description here

  • Related