【问题标题】:How to detect defect/missing pills in blister pack? (Matlab)如何检测泡罩包装中的缺陷/缺失药丸? (Matlab)
【发布时间】:2021-04-13 11:28:41
【问题描述】:

如何检测片剂条中的缺陷/缺失片剂。假设平板电脑条中缺少一个平板电脑。我试过stdfilt(),但图像包含很多噪音。我也尝试过平均和中值过滤,例如canny 和prewitt。我还在图像中添加了盐和纸等噪点。 有没有其他的分割方法?任何编码都会有所帮助

I2=rgb2gray(I);
J = imnoise(I2,'salt & pepper',0.02);
figure
imshow(J)
Kaverage = filter2(fspecial('average',3),J)/255;
figure
imshow(Kaverage)
Kmedian = medfilt2(J);
imshowpair(Kaverage,Kmedian,'montage')
BW1 = edge(Kmedian,'Canny');
BW2 = edge(Kmedian,'Prewitt');`

【问题讨论】:

  • 我会检测圆圈来分配药片的位置,查看每个位置的强度直方图,看看丢失的药片有什么部分的暗新月。基于此,如果有或没有药丸,我会使用阈值。

标签: image matlab image-processing


【解决方案1】:

这是基于我的评论的一种方法

% reduce to grayscale
d=rgb2gray(your_img);

% find edge and blur a bit so we can find circles
d2=conv2(edge(d),ones(9),'same');
d2=max(d2(:))-d2;

% find circles
Rmin = 71; Rmax = 80;
[center, radius] = imfindcircles(d2,[Rmin Rmax],'Sensitivity',0.98);

% Display what we found  
imagesc(d);axis square
hold on;
viscircles(center,radius);
plot(center(:,1),center(:,2),'yx','LineWidth',2);
hold off;

% histogram of each circle content:
[x, y]=meshgrid(1:size(d,2),1:size(d,1));

for n=1:numel(radius)

    circle_pixels{n}=find ((x-center(n,1)).^2+(y-center(n,2)).^2<=radius(n).^2);
    h(:,n) = histcounts(d(circle_pixels{n}),0:max(d(:)) );

    subplot(2,5,n); plot(h(:,n));title(['circle # ' num2str(n)]);
end

现在我们可以看到强度在每个圆圈中的分布情况,并选择一个指标来区分丢失的药片。我们可以看到,对于丢失的药丸(#5、#9、#10),我们的强度分布不那么简单(超过一个峰值),特别是由于眩光反射而发生的最大强度饱和可能是箔纸。因此,您现在可以选择基于该阈值的阈值,或者您想要的任何其他统计指标(分布中的峰值数等)...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-05
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多