问题
Is it possible to Extract any Shape that's in front of an image?
let's say we have an image of two objects 1 in front, the other is behind and a blank or transparent background.
can we extract the one in front and place it in a new image?
can this be done by detecting edge of frontal shape and then crop it?
This article is doing something near to my question :
Cropping Particular Region In Image Using C#
but i want to do it fully automated.
any help would be highly appreciated.
Thanks in advance.
回答1:
I think you cannot do this fully automated; however, there are maybe some semi-automated ways, at least, you need some prior information such as how far your object can be placed. Here are some of my suggestions.
First way(you have experience in implementing academic papers, you have some prior information about depth of object's place),
- Download a "scene - depth images database" from internet
- Get the average value of database
- Query K-Nearest-Neighbors of input image according to GISt of scene[1]
- Apply SIFT flow to align database scenes according to input scene
- Infer the depth
- Remove a certain range from image.
It's possible to infer rough depth map of an input image. By using this, you'll try to infer depth map of input image then remove the certain depth range which includes your object. You can check the paper[2] for more detailed explanation.

Example Depth Map from http://www.the.me/wp-content/uploads/2013/09/z-depth_map_expanding_exif_more_powerful_post-processing_2n.jpg
Second way(assumption: human input is allowed at the end of algorithm.), - Segment the image(you can find state of the art algorithm with a little search) - Select the contour that you want to remove.

Example Segmented Image from http://vision.ece.ucsb.edu/segmentation/edgeflow/images/garden_edge.gif
References:
[1]Aude Oliva Gist of the Scene
[2]Karsch, K.; Liu, C.; Kang, S.B. IEEE Transactions on Pattern Analysis and Machine Intelligence (TPAMI), 2014.
回答2:
OpenCV gives option for to extract contours of the objects. So convert your image to gray scale and given to the open CV , detect all the contours in your images. and from that select contours which will be required for your requirement. Since your project is on C# you can take a look of Emgu CV which is a cross platform .Net wrapper for OpenCV. Pl. refer to the below url where you can download the examples for Emgu CV.
http://sourceforge.net/projects/emguexample/?source=recommended
来源:https://stackoverflow.com/questions/29782124/how-to-extract-front-shape-in-an-image-in-c-sharp