i need to make a program where i have to detect the edge of a subimage (like a face in a portrait) using canny detector. then i need to filter that portion out and paste it in another background. it is like mixing 2 layers. can anybody give me any algorithm for this? or any idea about the process?
Asked
Active
Viewed 1,703 times
1 Answers
0
You are probably aware that the task of selecting a subimage is most known Region of Interest (ROI).
Edge detection with canny shouldn't be a problem since OpenCV implements it as cvCanny()
.
For what I understand you want to overlap two images. I suppose you want to add one image on top of each other? Take a look at step 2 on the first link I suggest: Adding Two Images with Different Size
If you want to BLEND them, then check these instructions. I have used them before to draw over the webcam window.

Community
- 1
- 1

karlphillip
- 92,053
- 36
- 243
- 426
-
thanks for your informations. i have gone through the ROI and how to crop the ROI and then add to another image of diff size. also i can select an ROI runtime using mouse. but the ROI is either rectangular or circular. but in my case it can be of any shape depending on the canny edge detector. then how can i select it with mouse and crop it? – Sayak Apr 19 '11 at 04:30
-
moreover, if i use canny edge detection, i have to convert the image to grayscale. after that how can i get the color b back? so i think i must use a new algorithm for edge detection. what u say? – Sayak Apr 19 '11 at 05:34
-
Canny will give a black/white image with a bunch of lines in it, representing the edges. At this point, you can scan the result of canny looking for dark/black pixels and at those locations replace them by the same pixels found on the colored image. That should populate the result of canny with it's equivalent colored pixels. – karlphillip Apr 19 '11 at 12:56
-
karl, I will try what you have said about canny. but how could i crop the detected portion of the image? after the edge gets selected, that portion of the image has to be a different layer what i can crop out. – Sayak Apr 20 '11 at 03:20
-
I don't understand what is your current problem. The idea is select a ROI in the original image, *image1*, and it will give you a new image, named *image2*, which will contain only the selected portion of the first image. Then you execute canny on *image2*, and after that you are ready to add/blend it to *image3* (which contains the background). Ain't this it? – karlphillip Apr 20 '11 at 03:37
-
@Karl... i tried to develop as u said. but several issues have arised.. 1. it would be very difficult for anybody to select a portion (e.g. face) or draw the edges perfectly. so the cropped image is not a perfect reproduction. (refer the images that i have sent you) 2. Refer this link- http://www.morethantechnical.com/2010/06/24/image-recoloring-using-gaussian-mixture-model-and-expectation-maximization-opencv-wcode/ i am not interested in the recoloring part. i just need to click (or click and drag) on the subimage (in this case the orange) and i should get the orange only – Sayak Apr 20 '11 at 08:20
-
@karlphillip the link to instructions is broken – chyno May 07 '16 at 17:09
-
@chyno That happens with +5 year old posts. – karlphillip May 07 '16 at 18:19