0

Firstly, I think Gaussian thresholding to be the suitable choice to binarize these images based on what I've read, that they are "useful for images with variable lightning conditions". If you think some other method is more suitable please let me know.

I have tried to apply adaptive thresholding on this image

    filter4_result = cv2.adaptiveThreshold(filter3_result, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, block_size=5, constant=20)

and this is the result that I am getting. As you can see, it detects the bird as a single blob but also detects some slightly dark spots on the bottom left and right. Do you think it's possible to have a set of parameter values in adaptive thresholding that I can apply to segment only the bird?

and if I should use some other technique than adaptive thresholding, which one should I go for?

I have also tried Otsu thresholding with the following statement and this is the result that I got with Otsu thresholding

    filter4_result=cv2.threshold(filter3_result,128,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)

Otsu thresholding excludes all the noise nicely but it breaks apart the bird into several individual blobs.

Isn't there a sweet spot that I can achieve with any of the methods where I only detect the bird and nothing else on the image? I don't even need a well defined outline of the bird. If it can just count each bird correctly, that would still be good enough.

Which thresholding method and correspondingly what parameter values should I use to achieve that?

  • Just use otsu thresholding and invert. Then get contours and discard the two large contours leaving only the small bird contour. Then draw the contour as white on a black background as a mask. Then use the mask to select only your bird in the original image. – fmw42 Aug 16 '23 at 15:13
  • @fmw42 After we discard the two large contours, that leaves us with single birds divided into several individual contours (if we are using Otsu thresholding). The solution that you suggest here, does it include somehow combining those separate blobs to make one single blob(a bird)? because I think that's the problem I'm dealing with. Thanks for your response! – Sa'ad MuHammad Aug 16 '23 at 19:24
  • After thresholding use some small kernel morphology to close up the bird into one object. Use open or close depending upon if the bird is black or white, resp. – fmw42 Aug 16 '23 at 21:36
  • @fmw42 I used a combination of opening and closing kernel morphology and that gave me pretty decent results! – Sa'ad MuHammad Aug 17 '23 at 16:48

0 Answers0