Ask Your Question
1

How to find photo inside image

asked 2013-06-04 07:52:15 -0500

klangner gravatar image

I would like to find photo inside image. Below is an example:

Original image

I suppose that first I need to find edges. So I tried 2 approaches: Edge Canny detector:

Canny detector

Adaptive Threshold (with Gaussian smoothing):

Adaptive threshold

As you can see the edges are not perfect. Any ideas how to improve edge detection. Or maybe there is a way to find photo from Canny detector in second image?

Thank you for any tips in advance.

edit retag flag offensive close merge delete

Comments

It's not clear what you actually want to do. Do you want to find this specific photo or do you want to rotate and crop a scanned image to extract all kinds of scanned photos?

Ben gravatar imageBen ( 2013-06-04 08:36:07 -0500 )edit

I have same images with single (internal) photo. The photos inside images are different and they are on different background. But there is only single photo on every image. I want to crop the image to the internal photo.

klangner gravatar imageklangner ( 2013-06-04 10:22:56 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
4

answered 2013-06-04 08:54:24 -0500

Guanta gravatar image

To get the photo-borders: From the canny-edge image compute the 4 longest surrounding lines via HoughLinesP and then compute the intersection points.

In this nice tutorial it is explained in more detail: http://opencv-code.com/tutorials/automatic-perspective-correction-for-quadrilateral-objects/

edit flag offensive delete link more

Comments

Thanks. This tutorial looks great. The problem is that in the tutorial Canny detector provides very clean edges. While in my case (second image) I have lots of noise. That's probably because the quality of my image is lower. Is there a way to improve quality of image to get better edges?

klangner gravatar imageklangner ( 2013-06-04 11:46:39 -0500 )edit
1

Typically you denoise your image (e.g. with Non-Local-Means, see http://docs.opencv.org/modules/photo/doc/denoising.html?highlight=fastnlmean#fastnlmeansdenoisingcolored). Furthermore, before you run Canny you also smooth the image with a small Gaussian (sigma~2). However, I think you won't need these two steps, since when using HoughLinesP you can say that your lines can have gaps and that it has to have a certain length, which makes it pretty much prone to image noise.

Guanta gravatar imageGuanta ( 2013-06-04 14:41:21 -0500 )edit
2

answered 2013-06-04 08:24:54 -0500

I guess you should take a look at the features2d tutorials where known objects are matched based on their local features.

Click here, here, here or here!

Last one does exactly what you need, but I would suggest using your time to go through first tutorials to grasp all the concepts used.

edit flag offensive delete link more

Comments

2

I think the task is not to find a specific photo, but to find the photo borders from a scanned image in order to rotate/crop it.

Ben gravatar imageBen ( 2013-06-04 08:34:02 -0500 )edit
1

It all depends on what he actually wants :) Else solution of @Guanta will be exactly what he is looking for.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-06-04 08:57:35 -0500 )edit
1

Thanks for the pointers. I will take all the tutorials. Regarding my task. Ben is correct. I don't know what kind of photo is on the image (and I don't know the background). So I'm looking for generic solution.

klangner gravatar imageklangner ( 2013-06-04 10:25:55 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2013-06-04 07:52:15 -0500

Seen: 635 times

Last updated: Jun 04 '13