ussrback
ussrback

Reputation: 621

Uneven background correction using Top hats

I am trying to correct uneven background illumination in the text document using Morphological top-hat operation. enter image description here

After applying Top hat, result I get is worse for analysis than the original image.

img=rgb2gray(imread("test2.png"));
se=strel("square",100);
imshow(imtophat(img,se));

enter image description here Could you please advice what i am doing wrong ?

Upvotes: 1

Views: 257

Answers (1)

Cris Luengo
Cris Luengo

Reputation: 60760

The top hat filter works for light text on a black background. You can either invert the image (imcomplement) before applying the top hat, or use imbothat instead.

In either case, the output is identical: light text on a black background. You can invert the image after the operation to get dark text on a white background.

Upvotes: 2

Related Questions