Clip
Clip

Reputation: 3078

Adaptive Bilateral Filter to preserve edges

I need to be able to detect the edges of a card, currently it works when the background is non-disruptive and best when it is contrasting but still works pretty well on a non-contrasting background.

The problem occurs when the card is on a disruptive background the bilateral filter lets in too much noise and causes inaccurate edge detection.

Here is the code I am using:

bilateralFilter(imgGray, detectedEdges, 0, 175, 3, 0);
Canny( detectedEdges, detectedEdges, 20, 65, 3 );

dilate(detectedEdges, detectedEdges, Mat::ones(3,3,CV_8UC1));

The imgGray being the grayscale version of the original image.

Here are some tests on a disruptive background and the results (contact info distorted in all images):

Colored card:

enter image description here

Result:

enter image description here

And here is a white card:

enter image description here

Results:

enter image description here

Can anyone tell me how I can preserve the edges of the card no matter the background, color while removing the noise?

Upvotes: 1

Views: 3962

Answers (1)

Pervez Alam
Pervez Alam

Reputation: 1256

Find the edges using canny which you are already doing, then find the contour in image and find the suitable rectangle using bounding box and apply some threshold on the occupancy and the dimensions of rectangle. This should zero down to your rectangle i.e. your card edges and take it as ROI on which you can further work.

Upvotes: 1

Related Questions