Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab - object segmentaion

How to use masks operations and morphological filters to segment the object as shown in image c: where a is the given image, b is the background(no idea why is this given), c is what we aim for:

enter image description here

I thought binarizing the image would help, but the result is like so:

enter image description here

otherwise, I Intuitively don't see how is that possible

I thought of "Segmentation Using Morphological Watersheds" but I am not sure if this is the right way to go

like image 592
Remi Moore Avatar asked Jun 08 '26 15:06

Remi Moore


1 Answers

Actually having the background makes this much easier:

A = im2double(rgb2gray(imread('a.png'))); % image
B = im2double(rgb2gray(imread('b.png'))); % background

D = abs(A-B)>0.12; % difference > threshold
D = imerode(D, strel('rectangle', [2 2])); % reducing spots
C = A;
C(D)=1; 
subplot 121, imshow(D)
subplot 122, imshow(C)

enter image description here

like image 75
saastn Avatar answered Jun 10 '26 11:06

saastn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!