I=im2double(im2gray(imread('image.png')));
BW=imbinarize(I);
D=bwareaopen(abs(gradient(I))>0.06,20);
D=imclose(D,strel('disk',5));
black=(median(BW,2)>0);
red=~black;
L=D.*red+2*D.*black;
imshow(labeloverlay(I,L,Colormap=[1,0,0;0,0,0]));
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!