如何(自动)测量图像中像素缺陷的大小? [英] How to ,measure the size of a defect in pixels in a image (automatically)?

查看:126
本文介绍了如何(自动)测量图像中像素缺陷的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个半导体的数字图像,其中有一个缺陷,我可以通过使用类似以下的分割技术来提取缺陷:

So I have a digital image of a semiconductor where there is a defect which I manage to extract by using segmentation techniques like this :

fig1 = imread('figure1.png');
imshow(fig1);

title('Original image', 'FontSize', 18);
%Gray image
fig1Gray = rgb2gray(fig1);



%Binary image
BW1 = imbinarize(fig1Gray,0.5);
imshow(BW1);
title('Binary image', 'FontSize', 18);

sr = strel('square',5);

%Dilation image
dilated1 = imdilate(BW1,sr);
imshow(dilated1);
title('Dilated image', 'FontSize', 18);

minus1 = ~(BW1-dilated1);
imshow(minus1);
title('Minus image', 'FontSize', 18);
imshowpair(minus1,BW1,'montage');

如何测量缺陷区域的大小(以像素为单位)?

How can I measure the size of the defected area in pixels?

编辑:添加了图片

推荐答案

您可以使用返回以下结构:

CC = 

  struct with fields:

    Connectivity: 8
       ImageSize: [247 247]
      NumObjects: 1
    PixelIdxList: {[404×1 double]}

假设您的预处理步骤正确,则缺陷区域的大小为:

Assuming your pre-processing stages are correct, the size of the defected area is:

length(CC.PixelIdxList{1})


您还可以使用 regionprops :

fig1 = imread('figure1.png');
fig1Gray = rgb2gray(fig1);
BW1 = imbinarize(fig1Gray,0.5);
stats = regionprops(~BW1, 'Area');
biggest_area = max([stats.Area]);

结果:最大面积= 404

Result: biggest_area = 404

用黄色标记该区域:

Y = im2uint8(cat(3, ones(size(BW1)), ones(size(BW1)), zeros(size(BW1))));
fig1(~cat(3, BW1, BW1, BW1)) = Y(~cat(3, BW1, BW1, BW1));
figure;imshow(fig1)

输出:

白色听起来也像是缺陷区域的一部分.
如果需要包括一些探测区域,请使用imdialte:

The white sounding also looks like a part of the defective region.
In case you need to include some of the sounding area, use imdialte:

BW2 = imdilate(~BW1, ones(5));fig1(cat(3, BW2, BW2, BW2)) = Y(cat(3, BW2, BW2, BW2));figure;imshow(fig1)

这篇关于如何(自动)测量图像中像素缺陷的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆