Reputation: 35
the following image is given
And I have to detect the the components at the bottom right of the image. the result should look something like this:
thresholding followed by erosion look like this in code:
clc; close all;
I = imread('Leiterplatte.png');
se = strel('rectangle', [2 4]);
Ie1 = imerode(I,se);
imshow(I);
%figure; histogram(I)
Im = Ie1>40 & Ie1<128;
figure; imshow(Im)
se = strel('rectangle', [8 8]);
Ie = imerode(Im,se);
figure; imshow(Ie)
I(Ie)=255;
figure; imshow(I)
And I get the following result:
but the detected rectangles are either too small or if not then the spots are still in the image like so:
Upvotes: 0
Views: 178
Reputation: 6015
You are almost there. A little play with constants and an imopen
call to remove spots will get the job done:
I = imread('RuaDN.png');
se = strel('rectangle', [4 8]);
Ie1 = imerode(I,se);
Im = Ie1>70 & Ie1<130;
se = strel('rectangle', [8 16]);
Ie = imopen(Im, se);
O = I;
O(Ie) = 255;
Upvotes: 2