MATLAB Answers

Segmentation of PCB iamge

3 views (last 30 days)
Wutt Yi Tun
Wutt Yi Tun on 14 Jan 2020
Commented: Wutt Yi Tun on 7 Feb 2020
Hello! Please help me.
I want to segment the PCB image "3(template).jpg" into line and pad segments. How do we segment this image.

  0 Comments

Sign in to comment.

Accepted Answer

Selva Karna
Selva Karna on 14 Jan 2020
Hi Check this code,
clc
clear all;
close all;
%%
rgb=imread('im.jpeg');
gray=rgb2gray(rgb);
bw=im2bw(~gray,0.2);
clrb=imdilate(bw,strel('disk',2,4));
I=rgb(:,:,1);
BW=clrb;
[nbwl,cnt]=bwlabel(BW);
msk=zeros(2020,2020);
for i=1:cnt
fhls=find(nbwl==i);
msk(fhls)=i;
seg=label2rgb(msk);
st=i;
imwrite(seg,sprintf('%d.jpg',i))
imshow(seg)
pause(0.8);
drawnow()
end
Results:

  0 Comments

Sign in to comment.

More Answers (2)

Selva Karna
Selva Karna on 14 Jan 2020
9.jpg

  0 Comments

Sign in to comment.


Selva Karna
Selva Karna on 14 Jan 2020
check this attachment

  3 Comments

Wutt Yi Tun
Wutt Yi Tun on 15 Jan 2020
Thank you for your answer. But I'm sorry for my imperfect question. I want to segment into lines and pads seperately.
Selva Karna
Selva Karna on 28 Jan 2020
yes, you just convert binary image & segment holes [white pixel list]
Wutt Yi Tun
Wutt Yi Tun on 7 Feb 2020
Thank you! I got the segmented images (holes, lines and pads seperately). Thank you so much!!!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!