<< 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

what us maxima and minima
MiXUP Reply
Maxima s below equilibrium. Whilst minima s above. Equilibrium
Afran
Wht is demand
Afran
is the willingness and the ability of a consumer to purchase goods at a given price and at a particular point in time.
Assan
Ohhk different question? Ask
Afran
why is the demand curve downwards sloppy?
Assan
3 Reasons.. 1... diminishing marginal utility 2... substitution effect 3...income effect
Harshita
thanks
Assan
Because of the negative or inverse relationship between price and quantity demanded
Afran
what is the law of diminishing returns states?
Assan
ohk
Assan
The law states that all other things being equall as much of variable factor(labour) is employed on fixed factor(land) the marginal product rises..attain a maximum and begins to fall.
Afran
What is income elasticity of demand
Afran
what is monetary policy
Edward
Monetary policy is an attempt to influence the economy by opera ting in such monetary variables
Afran
thanks
Edward
Wlcm
Afran
Wht is disutility?
Afran
is disutility? is rightly writing?
Yhlas
is it i wanna say
Yhlas
Yes please Disutility
Afran
what is macro economics?
Oyas
the branch of economics concerned with large-scale or general economic factors, such as interest rates and national productivity.
idk
in other words it is the study of the economic as a whole
idk
What is an Economic growth
Ayumo Reply
Economic growth is the process whereby the real per capita income of an economy increases over a long period of time.
Nureni
what is the generally accepted defination of economics and by who
IDY Reply
Economics is defined by Lionel Robbins as a social science which studies human behaviour as a relationship between ends and scarce means which have alternative uses
Tba
Importance of economic
Achike Reply
Helps in decision making
MP
I need like 5 importance
Achike
hi
Physcal
Hey
Muhammad
hellow dear.
juwel
hello
Al-ameen
Hello
MP
it helps an individual in rational decision making process
Assan
Fine and u
Buzabaryaho
how does it make individual in rational dicision making decisions
Annor
if an individual is faced with unlimited wants.
Assan
it also helps an individual in arranging their wants in order of their importance.
Assan
ohk
Annor
ok
Al-ameen
Hello guys
Radah
My name is Radah
Radah
Please what is a scale of preference used for?
Radah
it's use for arranging wants in order of their importance.
Assan
in other words when an individual is faced with unlimited wants,scale of preference would help the individual to select the most important wants.
Assan
Thanks
Radah
welcome
Assan
what is tourism
forgive Reply
Tourism is travel for pleasure or business
Yusuf
It is the commercial organization and operation of holidays and visits to places of interest.
Nureni
who is a price taker?
sam Reply
A price taker is a person or a company who have no control to dictate a prices of a goods or services
Unique
Someone who sets price
Nureni
In the trading world, a price taker is a trader who does not affect the price of the stock if he or she buys or sells shares.
Nureni
A price taker refers to a firm or an individual who sets the price of his good and services based on an external factor. In other words he cannot choose and set a price by himself. An example is a firm operating in perfect competition where prices are set through the price mechanism.
Tba
in a common and suitable sense state the law of diminishing returns
Unique Reply
The higher the satisfaction derived from a particular commodity,the lower the demand for it but that law doesn't match in some instances.
Nureni
state the features of an imperfect competitive market
Naomi
@NURENI instance like wat
Unique
imperfect competitive market involves large number of sellers and buyers price makers selling cost product differentiation free entry and exit of a firms
Unique
is economics a science
Alex Reply
yes. a social science.
Carlos
Yes of cause It uses scientific principles in its research. That is to say, analyzing data, making experiment as well as making deductions and drawing conclusions
Aziz
U can understand the scientific nature of economics by learning about the methods used by Abhijit Banerjee(indian) ,the nobel prize laureate 2019.
Harshita
it is considered as a social science
idk
Hence, economics is a science, a social science many can call it, or more appropriately, a young science
Taha
it can be called social science because of behaviour ,which is unpredictable.There r many theroies in economics which make economics a social science But some economic theories makes it science
Harshita
human behaviour*
Harshita
remember science derives from the root words "to know". With that being said most fields of study can be considered as a science or soft science, for they possess key knowledge to attaining understanding of our world.
Alexander
economics is a science cos it deals with human wants, desire or neads in order to satisfy them
Unique
according comparision of political science economic is science.
Hassan
what's the question?
Nureni Reply
Discuss economics system
Henry Reply
discuss institutional system
Henry
Give 3 at most advantages and disadvantages of economics system and institutional syatem
Henry
Give the features characteristics of market or free enterprise
Henry
The structure of an economy is largely determined by the economic system which is a function of the economic ideology of the nation
Nureni
The economic system is grouped into 5 groups: 1: Pure market 2: Developed market 3: Centrally planned or Socialist 4: Mixed market and 5: Market Socialist Economic systems
Nureni
what is inflation
Prince Reply
Inflation is a sustained and general rise in the price of all goods and services of an economy
Tba
hello everyone , I'm New here, third degree price discrimination?
Saeed Reply
2nd degree price discrimination?
Saeed
hi
Kini
hi
Mitchel
Hi
MP
price paid by consumers after the sales tax is called?
Pinias Reply
why government impose price floor on certain products?
Pinias
how can black market be occurred when price ceiling is introduced?
Pinias
How can inflation affect goods and services?
Ph
When prices rise for energy, food, commodities, and other goods and services, the entire economy is affected
Joan
If inflation becomes too high the economy can suffer conversely, if inflation is controlled and at reasonable levels, the economy may prosper. With controlled, lower inflation, employment increases.
Joan
Is it necessary to make decision when it fails you
Evelin Reply
Pls when what fails u
MP
I think so
Kini
well i might naught know what you on about but i gotta tell you, it is necessary
Troy
yep
Ibe
Kk
MP
yep
Ibe
how can the demand side approach solve unemployment
Tshepiso Reply
demand solves unemployment when it is addressed with supply you can't just expect demand to work alone without supply the two are interconnected
Nureni
You have to apply the concept of aggregate demand
Tba
That is apply demand side policies to boost aggregate demand hence increasing need for labour and decreasing unemployment(more people get jobs)
Tba
Researchers demonstrated that the hippocampus functions in memory processing by creating lesions in the hippocampi of rats, which resulted in ________.
Mapo Reply
The formulation of new memories is sometimes called ________, and the process of bringing up old memories is called ________.
Mapo Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





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