Ask Your Question
0

How to smooth the edges of a low quality image?

asked 2017-07-06 05:49:04 -0600

akash29 gravatar image

updated 2017-07-06 06:30:07 -0600

I am working on this picture.

Google Map Satellite Image

Due to its bad quality, firstly I use histogram equalization after that bilateral blur to preserve the edges, adaptive Canny and edge sharpening kernel and the output is this:-

Edge detection

I need the edges to be closed and gone through morphological operations but the results were not satisfactory and the operation can't be generalized on all the images. How to solve this? Here's the code:- Edge Sharp

edit retag flag offensive close merge delete

Comments

1

Well, for me the edges seem right. For a low resolution image with not much contrast that's what you can obtain.

If you want to extract the buildings, I would suggest a segmentation algorithm, like watershed.

kbarni gravatar imagekbarni ( 2017-07-06 11:31:24 -0600 )edit

Watershed is not helping in this matter. I have tried that. Maps of India are too bad that they can't even detect a contour in this low-quality image. I am going with the active contours on the Edge Detector Output but active contours are taking a lot of computation time. Any better approach would be really appreciated.

akash29 gravatar imageakash29 ( 2017-07-07 01:12:11 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-10-10 06:46:07 -0600

fiammante gravatar image

updated 2017-10-10 10:36:31 -0600

berak gravatar image

You can try use the opencv python code

blur = cv2.blur(img,(9,9))
blur2 = cv2.GaussianBlur(img,(3,3),0)

absd=cv2.equalizeHist(cv2.cvtColor(cv2.absdiff(blur2,blur),cv2.COLOR_BGR2GRAY))

The first blur gives long range variations the second blur gives short range variations

The absolute difference gets the gradient and if an object is half shaded invert the part under shade. The histogram equalization restores a gray scale range for visualisation.

In my test the one which gave me the best results for visualizing edges


image description

edit flag offensive delete link more

Comments

@berak Better like that? Sorry for the mistake. I was just looking for a place to put sample code without asking a question.

fiammante gravatar imagefiammante ( 2017-10-10 10:21:43 -0600 )edit
1

sure, and no worries !

berak gravatar imageberak ( 2017-10-10 10:23:06 -0600 )edit

@berak BTW I do think nobody had tried that before and it improved a lot my object recognition percentage in real life project. Instead of having 4 opencv calls it would be good if grouped in one new function in c++. Just give a try of the python above.

fiammante gravatar imagefiammante ( 2017-10-10 10:28:53 -0600 )edit

maybe ;)

let me look, again..

berak gravatar imageberak ( 2017-10-10 10:34:26 -0600 )edit

reminds me somewhat of "difference of gaussians".

if you'd invert it ? might be close to an answer !

berak gravatar imageberak ( 2017-10-10 11:32:14 -0600 )edit
1

@berak if you just make the difference of gaussians (which I tried), you don't get correction of objects that are partly under a shadow which is the reason for the absolute value. The difference also gives small numbers so the equalizehist becomes necessary to get something visible. Inverting will get you the edges as black but it is not important when you then use that in a neural network since what is important is the variations. I also tried different kernels and different blurs like medianblur.

fiammante gravatar imagefiammante ( 2017-10-10 11:50:31 -0600 )edit

aww, right. i did not think "this through to the end"

berak gravatar imageberak ( 2017-10-10 11:54:26 -0600 )edit

@berak I also tried before laplacian of gaussian, canny, findcontours etc.

fiammante gravatar imagefiammante ( 2017-10-10 11:56:41 -0600 )edit
1

@berak Surprisingly it also works quite well for better resolution and large images. I tried it with large car images from some Kaggle contests.

fiammante gravatar imagefiammante ( 2017-10-10 11:59:19 -0600 )edit

@fiammante, it might be an idea to add your edge enhancement approach as a new function to OpenCV through a PR with some sample code?

StevenPuttemans gravatar imageStevenPuttemans ( 2017-10-11 04:51:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-07-06 05:49:04 -0600

Seen: 9,658 times

Last updated: Oct 10 '17