if the distance is less it would output a smiling expression and if the distance is more it would output a neutral expression.
A = smile expression B = Neutral expression
A = 129;
B = 188;
Threshold = 155;
if A > B
error('threshold_grayscale_image : min_threshold is greater then max_threshold');
end
end
selected = (min_threshold >= A) & (B <= max_threshold);
thresholded_image(selected) = A;
return;

3 Kommentare

Anand
Anand am 17 Mär. 2014
Is there anyone who can help me out?
I really appreciate all the help!
sumi
sumi am 18 Mär. 2014
how to assign a threshold value...
Anand
Anand am 18 Mär. 2014
yes thats correct, any ideas?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Image Analyst
Image Analyst am 17 Mär. 2014

0 Stimmen

I don't know what you mean. Do you mean you want to display an image of someone smiling or neutral depending on the condition? Do you have images for those two cases?
And how are you determining the "distance"?

10 Kommentare

Anand
Anand am 17 Mär. 2014
Bearbeitet: Anand am 17 Mär. 2014
in order to output expressions from a recorder video I am using i must apply a threshold to it.The threshold must be trained to knows when to display smiling frame or a neutral frame. Yes i have both neutral and smiling face images with the distance calculated for both and also the threshold.
A = 129; %Smile Image distance
B = 188; %Neutral image distance
Threshold = 155; %Calculated threshold
All i want to do is set a threshold in this manner:-
Apply Threshold (T) to Distance (D)
Output Smile image if D < T
otherwise
Output Neutral Image if D > T
Its as simple as that, but i just cant figure out how to code it. I have all the figures, i just need your assistance on how to code as i cant get it right after multiple tries.
does this make sense?
Image Analyst
Image Analyst am 18 Mär. 2014
Where did you get the smile and neutral image distances from? Did some algorithm produce them? A smile is not something that is binary. There is a continuum from neutral to smiling and where you actually call the mouth and face shape "smiling" is a judgment call. You just need to decide on what number to use. There is no right answer. You could use anything in between 129 and 188. How about 170? What's wrong with that? Is there anyone who could tell you that that value is wrong?
Anand
Anand am 18 Mär. 2014
I took a photo on my webcam with both expressions, i then did corner detection to get the left most and right most points of the eyes and mouth. once i get left most and right most point on both expressions i use the SQRT method to calculate the distance. once i find the distance between eyes and mouth for both expressions i calculate average distance which brings me to 129 for the smiling face and 188 for neutral face.
Image Analyst
Image Analyst am 18 Mär. 2014
OK, so take a picture of someone just at the threshold/edge of smiling and not smiling. Then run your algorithm and use that value as the deciding point for smiling or not smiling.
Anand
Anand am 18 Mär. 2014
my supervisor told me that points you get from your corner detection determine your distance, so it really depends. There is an example of yours in the link i sent you yesterday, it had the closest example on how i want setup a threshold, all i want it to do is output smile image if distance is less than threshold and output neutral image if distance is greater than threshold. its a really straight forward concept.
Anand
Anand am 18 Mär. 2014
Bearbeitet: Anand am 18 Mär. 2014
YES, thats correct. and now i want to write a few lines that does the following:-
Output Smile image if D < T
and
Output Neutral Image if D > T
Any Ideas??
if D < T
imshow('smile image.png'); % Show smiley face or graphic.
uiwait(helpdlg('The face was smiling.'));
else
imshow('neutral image.png'); % Show clip art of a "flat affect" face.
uiwait(helpdlg('The face was neutral.'));
end
Anand
Anand am 18 Mär. 2014
ok thank you, but is this based on the distance or do i have to define them?
for example
A = 129;
B = 188;
Threshold = 155;
if D < T
imshow('smile image.png'); % Show smiley face or graphic.
uiwait(helpdlg('The face was smiling.'));
else
imshow('neutral image.png'); % Show clip art of a "flat affect" face.
uiwait(helpdlg('The face was neutral.'));
end
You defined T to be 155. You can call it T or Threshold, it doesn't matter, but they must be the same. A and B are just sample values from two of your images and are not really used. D is the actual value that your algorithm will calculate for whatever the current image is. You should add comments, right?
% D is the value for this face image.
% A typical value for a smiling face might be 129.
% A typical value for a neutral face might be 188.
% The threshold, or borderline, between smiling and not smiling
% is set to 155.
Anand
Anand am 18 Mär. 2014
Thank you ever so much!! I have got the threshold to run the want it to.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Gefragt:

am 17 Mär. 2014

Kommentiert:

am 18 Mär. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by