Search code examples
pythonopencvobject-detection

Use OpenCV to find breast cage area on mouse x-ray mages


I`m kind of new in OpenCV. I have a task to automate breast cage area calculation based on mouse x-ray. So now i only have o body contour.

Code i use

import cv2 as cv


img = cv.imread("sample.jpg")

gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

gray_gauss = cv.GaussianBlur(gray, (9, 9), 0)

ret, thresh = cv.threshold(gray_gauss, 130, 255, cv.THRESH_BINARY)

contours, _ = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_NONE)

cv.drawContours(img, contours, -1, (0, 255, 255), 2)

cv.imshow("thresh", thresh)
cv.imshow("main", img)
cv.waitKey(0)
cv.destroyAllWindows()

This is sample image mouse x-ray

The result i have enter image description here

Is any chance i can find only breast cage contour in this image?


Solution

  • If you want to go the tedious classic path, I would try finding rules step by step:

    1. Find the basic contours of the body.
    2. Find the legs.
    3. Estimate rectangular region around the chest by normal mouse proportions.
    4. Find landmarks in this region that can be used to outline the chest.

    If you find that the quality of the input image is too low and even a human being has to guess the area or estimate its position by experience then you will have to define rules for guessing, too.

    It's nearly impossible to find adequate rules from only one image and without human experience. This is why training a model with many examples and input from experts often is more reliable.