Find people at image - algorithm

I need to implement algorithm which for input has picture ( jpeg ) and create new picture like output, but only with bodies ( background is removed completely ). Input picture is picture with people from vacation and I need to recognize human bodies and remove background. Can someone suggest me what algorithm to use, what book to buy to learn that algorihms ?

Check this link it will perfectly answer your question of removing the background and performing further processing

neural networks are particuarly useful for this kind of task, but the theory is a universe, if you're doing it from scratch ... that's a lot of work

This is a segmentation problem. In the general case, segmenting images is a hard research problem (I just spent five years doing a doctorate on segmenting greyscale medical images, for example) and the way you go about it is strongly tied to the type of images with which you have to deal. The best advice I can give is to go and read the appropriate literature on segmenting colour images (e.g. use Google Scholar). In terms of books, this one's a good general-purpose introduction to image processing:
http://www.amazon.co.uk/Digital-Image-Processing-Rafael-Gonzalez/dp/0130946508/ref=sr_1_7?ie=UTF8&qid=1326236038&sr=8-7
Searching for "segmenting people in colour images" on Google seems to turn up some good links, incidentally.

I have a question for you: you want to implement this using an algorithm? If so, then it might require a lot of things to be done (provided you are new to the field of image processing).
Otherwise you may try using masking techniques in image editing software like Adobe Photoshop (that would hardly take 15 mins, depending upon how well you know it)
A good book to start with image processing techniques is: "Digital Image Processing" by Gonzalez and Woods; it starts from the basics, and explains stuff in depth.
Still it may take a lot of time to develop an algorithm to do this job. I recommend you use some library for the same. OpenCV(opensource computer vision) is an excellent choice. The library itself comes with demos which include programs for face detection etc. The inbuilt functions provide a variety of features (edge detection/Feature identification and extraction, you may have to use this) Here's the link
http://opencv.willowgarage.com/wiki/
The link provides a lot of reference material that you can make use of! :)

Start with facial recognition software and algorithms; they have been the most refined over the years and as long as all of your bodies have heads, you can use exif data to figure image capture orientation (of course you can't completely rely on that), sample the facial skin to get skin tone ranges, and find the attached body. Anything that is not head and body should be deleted. This process assumes that a person has roughly the same skin tone on their face as their body and the camera flash isn't washing this out. You could grab the flash duration and some other attributes from exif and adjust your ranges accordingly.
A lot of software out there can recognize faces (look at iPhoto for example), so you'll have to use the face as a reference point, along with skin tone, to find your body edges. You result isn't going to be perfect, but as long as your approach is sound, you'll end up with something useful.
And release your software as open source when you're done so I can use it... :)

You can download a free PDF of the book Computer Vision by Richard Szeliski from the author's website. Not only do you have a free book on algorithms, but it's a book that addresses this specific problem.
http://szeliski.org/Book/
You'll see this image at the top of that page of the author's website.
Used copies of the hardcover are available for about $62 if you check addall.com. If you spent some time doing image processing, you'll appreciate having a paper copy of at least one good general reference book.

Its tough but not impossible. I can't give you any code but Peter Norvig had a great talk on the value of data and in the talk he shows how he was able to take a picture of lake and remove all the houses blocking the image and have the lake expanded with boats,etc..
The computer basically learned how lakes look and boats go on lakes and then removed the houses and placed it there. He explains his process(but no code or anything).
Here it is:
Peter Norvig - The Unreasonable Effectiveness of Data
http://www.youtube.com/watch?v=yvDCzhbjYWs

Related

How to programmatically distinguish the professional photo from the amateur photo?

What are the different options and solutions (software) that will help distinguish professional (good) from amateur (bad) photo?
The criteria can be the contrast, sharpness, noise, presence of compression artifacts, etc. The question is, what are the tools that allow all this to determine it (the machine, not the man). For all of these criteria can be represented as mathematical models, you think?
Or in other words - to "feed" tool 1000 high-quality photos and 1000 substandard. And machine itself has identified the factors that distinguish the good from the bad image.
This is a quite vague definition of a problem. The only thing you have is 1000 high-quality photos and 1000 substandard photos. Your application however, is quite concrete, and I doubt (but I'm not sure) that you will find such a software.
Without looking to your images and have some tests is also difficult to say if contrast/gamma would be enough to classify them properly.
What you can do, if you know a bit of coding in matlab/python/C, is to use some existing libraries to try to solve your problem. I can't help you with that, as this itself is a quite tedious work, but, I can give you some insights.
To define your problem you will need:
Input: 1000 pro images, 1000 std images
You can represent this as 2000 images and a 2000 binary vector (1 for pro, 0 for std)
Features
Images itself might not give you enough information. What you can do is extract features from images. This step is called feature extraction and is an open research field in Computer Vision. There several feature extractors out there, you can try a couple of the most used ones, such as HoG or SIFT (have a look here for examples).
This feature extractors will give you a 1xM numerical vector for each image. With N images, you have a NxM matrix composed of N images and their descriptor.
Classification:
Once you managed to extract features from the image, having X = NxM data and y = label binary vector, you can use any machine learning algorithm, such as Deep Neural Networks, Random Forests, Supported Vector Machines, or any other one, to train your data, and classify it later.
By putting everything together, you might be able to get decent results.
Is this professional vs amateur photographer or equipment classification? I mean like distinguishing between a DLSR photo or a cell phone photo. Or is this distinguishing between an amateur with a DLSR and a professional with the same equipment? Or, are we talking about photoshop editing at the end.
In the case of equipment, I think features to look at would be noise, contrast, color gamut. In the case of skill of the photographer, you will probably have to look at features based on edge representations, natural scene metrics etc.
But, you will need to create a data matrix and then run a machine learning classification algorithm on it and hopefully find some features.
Are you making or looking for art for humans or for robots?
The definition of a great photo is subjective by definition. What to one person may be junk to another is genius. Trying to take that and turn it into an equation is asking for AI to take over humankind.
I don't mean to be harsh in my assessment. My degree is in Fine Art, Painting. I put a lot of time and effort into thinking about images. It's a wonder to me how a child might make an image that seemed to be thoughtless but was a breakthrough in my perception. Conversely you can work for hours, day, months or even years and then feel like the result just doesn't measure up.
Photography is an ingenious invention, therefore all photography is a source for amazement.
I do agree with you however. Some photos are truly impressive. I think that if we approach this as coders than what we are seeking is 'likes' or 'page views' or some other method of getting counts from many people. I know that is not the answer you were looking for but I don't think you can find a better one. I wish you well on your quest.
If you want to judge a photo on technicalities then the edge of the physics should be your target. Currently that would be mirrorless cameras and 3d imaging.

Image Processing algorithm for forensic application

Greetings,
I am trying to write an algorithm in MATLAB for detecting modifications in an image. Specifically, in the image I have to process, there was a person who was removed (using photoshop) and the space was filled with background pixels (which is a white wall). I was trying to detect reapeated patterns (using background blocks) but this method is not efficient. Do you guys have any ideas on how to do this in MATLAB? Thanks in advance.
Forensic image analysis is a fairly big research field, with huge applications ranging from law enforcement to show-biz. It's a huge (but very complicated) problem with lots of parameters, so don't be surprised if you don't find a lot of code examples available.
Before you even think about the technology you're going to use to implement it (e.g. to MATLAB or not to MATLAB), you should take a step back and think about the actual algorithm. You should also do your homework and perform a research survey using a site like Google Scholar.
Here's a couple of points to get you started:
One of the biggest guys in image forensics is Hany Farid. Check out his website. Read his papers, read the papers that he cites, and the papers that cite him. Be sure to watch the videos there too.
Dealing with compressed images actually helps image forensics. Read about blocking artifacts in JPEG images (most common image compression format). This link is a starting point, don't be shy to put a bit of effort in and look it up elsewhere, like Google Scholar.
Think about how editing the image alters the artifacts -- does it destroy them, replace them, modify them in some detectable way?
Read about fourier analysis -- it is a useful tool for image forensics
Be prepared to easily spend days or weeks on researching this problem.
Thanks for such interesting question. Indeed image forgery detection (as it is called) is a really big and very complex field. And there are many sub-fields (or sub-problems) within it. However you are talking about specific sub-problem of image forgery, which is called copy-move forgery detection. Here are some papers about it:
Detection of Copy-Move Forgery in Digital Images
Exposing Digital Forgeries by Detecting Duplicated Image Regions
You can find more papers about it in google scholar if you like.
Some time ago i was trying to code copy-move forgery detection with my own ad-hoc algorithm implemented in Python. If you want you can read about it in my blog article (code included). Detection script is very slow and not very reliable, but that being said has over 200 lines of code and has 8 adjustable script parameters. So this really shows that even one needs to code ad-hoc algorithm for forgery detection - he/she must work very hard to make something usable.
Good luck.
double compression detection
copy move forgery
splicing
retouching
any many more
Above given are the area in which research are going on, recently there is forgery incident found in medical class images also.
in copy move you can go for block -wise detection technique ,just extract the feature from a overlapping block by using dimension reductionality or by any transform technique and after that match the block......

Help to learn Image Search algorithm

I am a beginner in image processing. I want to write an application in C++ or in C# for
Searching an image in a list of images
Searching for a particular feature (for e.g. face) in a list of images.
Can anybody suggest where should I start from?
What all should I learn before doing this?
Where can I find the correct information regarding this?
In terms of the second one, you should start off with learning how to solve the decision problem of whether a square patch contains a face (or whatever kind of object you are interested in). For that, I suggest you study a little bit of machine learning, the AdaBoost algorithm, Haar features, and Viola-Jones.
Once you know how to do that, the trick is really just to take a sliding window across your image, feeding the contents of that window into your detector. Then you shrink your main input image and repeat the process until your input image has gotten smaller than the minimum size input for your detector. There are, of course, several clever ways to parallelize the computation and speed it up, but the binary detector is really the interesting part of the process.
You may find some of the material linked from the CSE 517: Machine Learning - Syllabus helpful in getting into machine learning and understanding AdaBoost. You will certainly find the Viola-Jones paper of interest.

Determine the differences between two nearly identical photographs

This is a fairly broad question; what tools/libraries exist to take two photographs that are not identical, but extremely similar, and identify the specific differences between them?
An example would be to take a picture of my couch on Friday after my girlfriend is done cleaning and before a long weekend of having friends over, drinking, and playing rock band. Two days later I take a second photo of the couch; lighting is identical, the couch hasn't moved a milimeter, and I use a tripod in a fixed location.
What tools could I use to generate a diff of the images, or a third heatmap image of the differences? Are there any tools for .NET?
This depends largely on the image format and compression. But, at the end of the day, you are probably taking two rasters and comparing them pixel by pixel.
Take a look at the Perceptual Image Difference Utility.
The most obvious way to see every tiny, normally nigh-imperceptible difference, would be to XOR the pixel data. If the lighting is even slightly different, though, it might be too much. Differencing (subtracting) the pixel data might be more what you're looking for, depending on how subtle the differences are.
One place to start is with a rich image processing library such as IM. You can dabble with its operators interactively with the IMlab tool, call it directly from C or C++, or use its really decent Lua binding to drive it from Lua. It supports a wide array of operations on bitmaps, as well as an extensible library of file formats.
Even if you haven't deliberately moved anything, you might want to use an algorithm such as SIFT to get good sub-pixel quality alignment between the frames. Unless you want to treat the camera as fixed and detect motion of the couch as well.
I wrote this free .NET application using the toolkit my company makes (DotImage). It has a very simple algorithm, but the code is open source if you want to play with it -- you could adapt the algorithm to .NET Image classes if you don't want to buy a copy of DotImage.
http://www.atalasoft.com/cs/blogs/31appsin31days/archive/2008/05/13/image-difference-utility.aspx
Check out Andrew Kirillov's article on CodeProject. He wrote a C# application using the AForge.NET computer vision library to detect motion. On the AForge.NET website, there's a discussion of two frame differences for motion detection.
It's an interesting question. I can't refer you to any specific libraries, but the process you're asking about is basically a minimal case of motion compensation. This is the way that MPEG (MP4, DIVX, whatever) video manages to compress video so extremely well; you might look into MPEG for some information about the way those motion compensation algorithms are implemented.
One other thing to keep in mind; JPEG compression is a block-based compression; much of the benefit that MPEG brings from things is to actually do a block comparison. If most of your image (say the background) is the same from one image to the next, those blocks will be unchanged. It's a quick way to reduce the amount of data needed to be compared.
just use the .net imaging classes, create a new bitmap() x 2 and look at the R & G & B values of each pixel, you can also look at the A (Alpha/transparency) values if you want to when determining difference.
also a note, using the getPixel(y, x) method can be vastly slow, there is another way to get the entire image (less elegant) and for each ing through it yourself if i remember it was called the getBitmap or something similar, look in the imaging/bitmap classes & read some tutes they really are all you need & aren't that difficult to use, dont go third party unless you have to.

How to design an approximate solution algorithm

I want to write an algorithm that can take parts of a picture and match them to another picture of the same object.
For example, If I gave the computer a picture of a vase and a picture of a scene with the vase in it, I'd expect it to determine where in the image the vase is.
How would I begin to develop an algorithm like this?
The final usage for this algorithm will be an application that for example with a picture of somebody's face could tell if they were in a crowd of people. This algorithm would eventually be applied to video streams.
edit: I'm not expecting an actual solution to this problem as I don't hope to solve it anytime soon. The real question was how do you define something like this to a computer so that you could make an algorithm to do it.
Thanks
A former teacher of mine wrote his doctorate thesis on a similar sort of problem, except his input was a detailed 3D model of something, which he would use to find that object in 2D images. This is a VERY non-trivial problem, there is no single 'answer', certainly nothing that would fit the Stack Overflow format.
My best answer: gather a ton of money and hire a very experienced programmer.
Best of luck to you.
The first problem you describe and the second are both quite different.
A major part of each is solved by the numerous machine vision libraries available. You may need a combination of techniques to achieve any success at either task.
In the first one, you would need something that generically recognizes objects. Probably i'd use a number of algorithms in concert to identify the foreground object in the model image and then do some kind of weighted comparison of the partitioned target image.
In the second case, examining faces, is a much more difficult problem relative to the general recognizer above. Faces all look the same, or nearly so. The things that a general recognizer would notice aren't likely to be good for differentiating faces. You need an algorithm already tuned to facial recognition. Fortunately this is a rapidly maturing field and you can probably do this as well as the first case, but with a different set of functions.
The simple answer is, find a mathematical way to describe faces, that can account for angles and partial missing data, then refine and teach it.
Apparently apple has done something like this, however, it still makes mistakes and has to be taught as it moves forward.
I expect it will be more about the math, than about the programming.
I think you will find this to be quite a challenge. This is an extremely difficult problem and is one of the many areas of computing that fall under the domain of artificial intelligence (AI). Facial recognition would certainly be the most popular variant of this problem and in spite of what you may read in the media, any claimed success are not what they are made out to be. I think the closest solutions involve neural nets and they require very clear and carefully selected images usually.
You could try reading here though. Good luck!

Resources