java如何去除噪点,消除黑白图像中的噪点

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?

s1nq7.jpg

original image

afCDL.jpg

解决方案

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:

Converted the given umage to gray scale:

mTMSc.jpg

Then I applied bilateral filtering to preserve edges and smoothen non-edges:

A9Xc4.jpg

(If you look intently you can see the difference).

Applied Gaussian blur to the above image:

w2TbT.jpg

Now performed DoG with the above two images to obtain this: (I merely subtracted the two images above)

a5D0K.jpg

Then I performed Morphological operation using the ellipse kernel to enhance the edge of the cell:

LK3Ak.jpg

To remove the unwanted speckles around the image I performed median filtering and finally obtained this:

Ekgt8.jpg

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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值