<< Chapter < Page Chapter >> Page >

Algorithmically our red cup replacement algorithm breaks down into three main sections: cup identification, finding a suitable replacement image, and the merger of the found image into the original.  Each part presents its own technical challenges and solutions.

Identification

Our test identification algorithm is based on simple template matching.  Basically, the template image of a desired object is convolved with the original image and the correlation between the two is found at every point.  The correlation is then normalized with respect to the intensity of the original image, giving a correlation value in the range between -1 and 1.  This process is encapsulated in the matlab function normxcorr2, whith takes two grayscale image matrices and returns one correlation matrix whose width and height are the sum of the widths and heights of the original matrices.  

The program sets a threshold value (around .7 by experimentation) to determine if our template has matched a cup in the original image.  Each color channel runs and is compared with the threshold separately.  The program then ands the resulting filtered correlation matrices together so a match is only found if it matches in terms of red, green, and blue.  This prevents a red (100% red, 0% green, 0% blue) from matching with white (100% red, 100% green, 100% blue).  At this stage, all points that exceed the threshold are considered matches.  Inorder to find the actual location of the cup the algorithm finds the maximum correlation overall, records a cup at that location, and then masks out the area of the found cup.  This neutralizes the other over threshold points around corresponding to the same cup, preventing overlapping cup hits.  The algorithm then finds the next greatest maximum value and repeats until all points over threshold have been accounted.

Unfortunately, this approach only works for one size of cup in the source image (the size of the template).  To detect all cup sizes the scale of the template relative to the source image must change and the correlation must be run for each respective size.  Our algorithm scales down the original image using imresize and leaves the template small (to save on runtime by reducing the correlation size instead of increasing it).  After each small change in size the correlation function runs and saves matched regions to an accumulation array.  The function also keeps track of the masks of previous match regions so smaller cups aren’t found erroneously inside of larger cups.  The match regions are recorded at the scale of the original image, so the algorithm keeps track of the scale factor at each step and sizes the recorded region accordingly.

The search algorithm builds on the idea of template matching and expands it to a wider scope.  Ideally the program would exactly match the regions around each cup and ignore the cup itself.  Since our correlation function can not exclude the middle area, we had to use a different approach.  The replacement algorithm generates blocks around the found cup with a width proportional to the size of the cup to be replaced.  Each individual block is then correlated through the image bank (similarly to as explained above).  The main difference is that the search algorithm must consider all blocks simultaneously-- a match is only a match if it works all the way around the suspect region.  To achieve this, the correlation matrices for each block are shifted and merged by the displacement of the block from the origin of the replacement image.  This generates a correlation matrix that takes all blocks into account.  The algorithm then finds the region with the highest correlation from all the images, and passes that region to the merge algorithm.

We built our test image bank from a relatively small number of images and just used Matlab’s imread function to load each one serially.  The program runs the above block based correlation on each image, keeping track of the highest correlation value and its assosciated region.

Because of the block nature of the search algorithm, one simple improvement we made was to give the blocks different weights based on their importance to the continuity of the image.  The human eye sees lines and edges more than muted textures, so we gave more weight (by multipying their correlation matrices by a factor before the final correlation sum) to blocks that contained more edges.  This modification helped ensure that arms stayed continuous and helped with the hand problem (the frequent presence of hands over the cup).  

Combination

After finding a region to suitably replace the excised region from the original image, the new image is blended with the original.  We used a conditional blend to completely replace the red cup, and then gradually blended the surrounding buffer regions together with the original image.   Our blend algorithm used a linear intensity blend (scaled sum of the two images), but could be quickly improved with bicubic blur (taking blur information from above and below as well) and a more consistent merger (angled corners).  

Questions & Answers

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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