-1

First image is the Original image. Second image is the Processed image. The image consists of a test tube containing some amount of precipitate at the bottom. I am trying to crop out only the Precipitate area of the image.

For achieving this, I have tried processing the original image so that the Upper edge of precipitate is detected. I am able to detect the upper edge of precipitate as you can see in the Processed image.

My question is, how do I crop the image from that upper edge to the bottom of test tube using OpenCV (Python) or some other library perhaps ? I am open to ideas and codes that can help. Thanks!

Original image Processed image

Markus
  • 5,976
  • 5
  • 6
  • 21
  • Does this answer your question? [How to crop an image in OpenCV using Python](https://stackoverflow.com/questions/15589517/how-to-crop-an-image-in-opencv-using-python) – Markus Feb 17 '23 at 13:44
  • @Markus It helps with the cropping part. But the main problem is, how will my program know where the precipitate edge is ? – Mohit Srivastava Feb 17 '23 at 17:40

1 Answers1

0

The surface of the precipitate is bright.

This is what you can get by getting the saturation component, applying Gaussian filtering horizontally and binarizing.

enter image description here

Horizontal delimitation of the ROI should not be difficult.

  • Can you please share the code for this ? I will test it on different images to see if it works for most test cases. Also, once we have this white line, we can run Hough line detection or something like that and draw a line passing through this white mark. Then get the Y coordinate of that line. That way we will know where the cropping has to begin. Am I right ? – Mohit Srivastava Feb 18 '23 at 04:53
  • @MohitSrivastava: no Hough, just take the center. –  Feb 18 '23 at 13:03
  • Thanks! I am new to OpenCV. Still exploring the thing. Thanks a lot man. I am however not clear how to find the saturation component as you stated. Can you please share your code for that ? – Mohit Srivastava Feb 18 '23 at 19:45
  • @MohitSrivastava: was made with own software. –  Feb 18 '23 at 19:46