我仅从捕获的图像(RGBImg_Raw)中分割了一个瓶子。接下来,我要检测这个小孔。但是,我无法继续进行。
我尝试使用jucetain在这篇文章中filt_img = imfilter(img, fspecial('log',31,5));
建议的方法。但这似乎也不起作用。我得到一个全黑的图像。
我还尝试检测具有各种阈值的Canny和Sobel图像边缘,但噪音很大。
I2 = adapthisteq(GrayImg); BW1 = edge(I2,'canny',0.05); BW1 = edge(I2,'sobel',0.1);
我希望在该针孔周围有一个圆圈,所以我可以找到连接的组件并检测该孔。
有什么建议?
我正在使用MATLAB。附件在Dropbox上。
这里使用来自FEX的快速2d峰值查找器:
% this part reads the image and gets rid of the white frame around it
d=imread('http://i.stack.imgur.com/MSQLZ.png');
d=rgb2gray(d);
d(d==255)=0;
% now peak finding with threshold as 0.8*max image intensity
p=FastPeakFind(d,max(d(:))*0.8);
figure;
imagesc(d); hold on
plot(p(1:2:end),p(2:2:end),'rx')
% the peak is found at
p =
735
355
编辑:
对于其他图像,平坦的阈值不适合。为了使其正常工作,您需要应用局部阈值,或者对图像执行称为“共模校正”的操作。一些相机产生的成像数据不应直接用于分析,而需要进行校正。最受欢迎的校正包括:暗率(基值)减法,不良像素遮罩,共模校正,增益校正等。无需过多讨论(您可以搜索上述内容的更多信息),则可以执行以下“计算”技巧,采用您要分析的图像的局部均值:
d=GrayImg;
% Read comments in the FEX of the 2d fast peak find, is all there
ws=100; % window size
mean_d=imfilter(d,fspecial('average',ws),'replicate'); % this a local mean operation
dd=d-mean_d;
filt = (fspecial('gaussian', 7,1));
p=FastPeakFind(dd,40,filt,600 );
imagesc(dd); hold on
plot(p(1:2:end),p(2:2:end),'wx');
所以我将edg设置为600,因为我很懒。最好的办法是将以上内容应用到图像的感兴趣区域,这样您就可以避免圆柱的边缘产生虚假的峰。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句