1

I have trimmed an image like this...

enter image description here

to minimise the black background around it using the PIL libary. As follows

enter image description here

But I need the result to maintain its thumbnail dimensions and maintain the aspect ratio and centring of the image. So in my example, (image2) I would need a little more height. I have tried to use the thumbnail function in PIL, opencv resize and also the imutils library without success. Keep in mind that the I have many of these images and the image of the Lungs in the middle will vary slightly in size so my trim function is dynamic to take care of that.

GhostRider
  • 2,109
  • 7
  • 35
  • 53
  • use a blob detecter in opencv, than you know where your important image data is https://www.learnopencv.com/blob-detection-using-opencv-python-c/ – user1767754 Nov 25 '17 at 10:45

0 Answers0