weiwen
weiwen

Reputation: 466

Line detection against darker shades

I wants to detect lines from an image with black line drawing over white papers. It could be easy if its ideal 'black and white', using histogram threshold would do.

But, as the image attached shows, some lines (e.g. in the light red circle) are in gray lighter than the shades (e.g. in the dark red circle). So some shades are obtained before light lines using histogram threshold.

Shades darker than some Lines.

Is there any ideas to divide lines from shades with some 'knowledge'? Thanks!


Edit: Here are the raw images, a bit small because they are of original resolution.

lines.bmp shades.bmp

Thanks :-)

Upvotes: 2

Views: 535

Answers (1)

lennon310
lennon310

Reputation: 12689

I would add another method using Gaussian blur other than erosion+dilation, for your reference:

file='https://i.sstatic.net/oEjtT.png';
I=imread(file);
h = fspecial('gaussian',5,4);
I1=imfilter(I,h,'replicate');
h = fspecial('gaussian',5);
I2=imfilter(I,h,'replicate');
I3=I1-I2;
I3=double(I3(:,:,1));
I3=I3.*(I3>5);
imshow(I3)

enter image description here

Upvotes: 1

Related Questions