Home > Enterprise >  How do you segment the darker spots from the blurry gray corners?
How do you segment the darker spots from the blurry gray corners?

Time:12-01

I'm trying to segment the dark grayish spots from the blurry gray areas on the corner, I did binary thresholding and morphological operations and it works great from the blobs in the middle, but the corners I'm having a bit of trouble.

enter image description here

import cv2
import numpy as np

# read the image
img = cv2.imread('dark_spots.jpg')

# convert to gray
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# blur
smooth = cv2.GaussianBlur(gray, None, sigmaX=10, sigmaY=10)

# divide gray by morphology image
division = cv2.divide(gray, smooth, scale=255)

# save results
cv2.imwrite('dark_spots_division.jpg',division)

# show results
cv2.imshow('smooth', smooth)  
cv2.imshow('division', division)  
cv2.waitKey(0)
cv2.destroyAllWindows()

Results:

enter image description here

  • Related