Calculate region areas in specific shape

I have an image of specimen that has 3 regions of interest as the white areas. I would like to estimate area of each region of interest.

enter image description here

My segmentation code is

image1 = cv2.imread('/content/1622542016610 copy.jpg')
img_gray1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
ret, thresh1 = cv2.threshold(img_gray1, 120, 250, cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(thresh1, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)

image_copy1 = image1.copy()

cv2.drawContours(image_copy1, contours, -1, (0, 255, 0), 2, cv2.LINE_AA)

plt.imshow(image_copy1)
plt.title('LIST')
plt.show() 

It could not give a very good segmentation as I expected, especially on the below left and below right. May I have your suggestions for

  1. How to improve the segmentation quality?
  2. Suppose I have the acceptable segmentation output, how to extract each region to count the number of pixels
  3. Is the number of pixels in a region represents the area (in physical measurement)?

The original image is this image.

enter image description here

Upvotes: 0

Views: 484

Answers (1)

pullidea-dev
pullidea-dev

Reputation: 1803

I think this solution needs two steps for the ideal segmentation.

The 1st step is the segmentation of only the Petri dish.

The next step is binarization of the Petri dish area.

2 steps are all binarization with different threshold values.

I think the 1st threshold value might be 40-45.

The 2nd threshold value must be determined using a histogram of the Petri dish area.

The final step is the identification and measuring of white areas.

PS. Q: Does the number of pixels in a region represent the area (in physical measurement)?

A: Yes. If you know the diameter of this Petri dish, you can calculate the actual area of the white areas.

Upvotes: 0

Related Questions