how can i assign value to image ? for example i have image ('apple') and image ('banana') I want to give ('apple') value = 5 and I want to give ('banana') value = 8 then compare between these two image and choose the max value so how can i do it in matlab

Réponses (2)

Stephen23
Stephen23 le 1 Mar 2015
Modifié(e) : Stephen23 le 1 Mar 2015

0 votes

Presumably you have more than two images, in which case using a structure might be the best solution:
A.apple = 5
A.banana = 8
A.coconut = 3
You can then refer get the maximum value of any elements that you want to:
max([A.apple, A.banana])
Note that you can also use dynamic fieldnames, eg:
A.('banana')
is the same thing as
A.banana
Image Analyst
Image Analyst le 1 Mar 2015

0 votes

You need to develop an image classification algorithm to determine what's in the image. For example, just look at the dominant color and decide if it's an image of an apple or a banana. Then return the classification. Make a function for that, in pseudocode:
function theClass = ClassifyImage(rgbImage)
if main color = red
theClass = 5
else if main color = yellow
theClass = 8
end
and so on. Then you can do the comparison you want with the values. I have several color classification tutorials in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by