I used MATLAB to generate this image (using bwareaopen
). In the middle I have a 2D ellipsoid. How can I clear all the "noise" surrounding of it and get a clear ellipsoid?
original image
Have a look at this solution. As mentioned in the comments I used DoG - Difference of Gaussians
What does DoG mean ?
First you have to take two separate Gaussians of an image with two separate kernels. (By Gaussian I mean apply ing gaussian blur). The difference of the two resultants is called the DoG.
This is what I did:
(If you look intently you can see the difference).
You can refine this process to get an enhance image .
EDIT:
Here is the code I used:
import cv2
filename = 'Cell.jpg'
img = cv2.imread(filename)
cv2.imwrite('img.jpg',img)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imwrite('gray.jpg',gray)
bi = cv2.bilateralFilter(gray,7,75,75)
cv2.imwrite('bi.jpg',bi)
blur = cv2.GaussianBlur(bi,(3,3),0)
cv2.imwrite('blur.jpg',blur)
blur1 = cv2.GaussianBlur(bi,(17,17),0)
dog = blur1 - bi
cv2.imwrite('DoG.jpg',dog)
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
close = cv2.morphologyEx(dog, cv2.MORPH_CLOSE, kernel, 13)
cv2.imwrite('close.jpg',close)
median = cv2.medianBlur(close,3)
cv2.imwrite('median.jpg',median)
cv2.waitKey(0)
cv2.destroyAllWindows()