<< Chapter < Page Chapter >> Page >

Replacement

Once all of the cups have been identified the replacement process begins by breaking up the area surrounding each cup into small boxes and examining each one individually. We then cycle through a bank of re-sized possible replacement images, breaking the corresponding area into the same sized chunks.  We calculate the cross correlation between each box, giving us an idea as to how well the replacement image matches the area surrounding the cup in the actual picture.  In order for the final product to look cohesive, the replacement image needs to “fit” the area surrounding the hole left by the cup.  The correlation between the cup itself and the object in the replacement image are inconsequential because the object will completely replace the cup after the replacement. Thus, only the correlation of the surrounding areas determine the selection of our replacement image.

The correlation of each pair of boxes is calculated in the same way as in the identification process, by taking the sum of products of each pixel. Once every pair of boxes has had its correlation calculated, the best match in the replacement bank is determined, and is placed in the position the detected red cup occupies. The best match does not necessarily have the most boxes with the highest correlation, or have the highest total correlation. Instead, some boxes are given a greater weight based on results from running an edge detector on each box. If the box contains more edges, it is given a greater weight. This is because it is most important to match edges when replacing the red solo cup, particularly hands. It is more obvious when edges do not match, and therefore edges are given a higher priority when selecting a replacement image. The replacement bank contains pictures of objects being held in hands in different orientations, so this methodology of weighting the boxes differently should lead to the most visually pleasing replacement possible.

The surrounding areas whose correlation was calculated are blurred and combined with the area surrounding the hole using a simple linear intensity blend to further facilitate blending of the replacement image with the image being filtered.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Red cup replacement. OpenStax CNX. Dec 19, 2011 Download for free at http://cnx.org/content/col11390/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Red cup replacement' conversation and receive update notifications?

Ask