OK! I GET IT! And that work nicely.. And i need to learn english when i read the help section:
[row,col,v] = find(X, ...) returns a column or row vector v of the nonzero entries in X, as well as row and column indices. If X is a logical expression, then v is a logical array. Output v contains the non-zero elements of the logical array obtained by evaluating the expression X.
So v is the list of the values!!!!
[row col v] = find(img);
[x]=size (v);
one_cents1=0;
two_cents1=0;
five_cents1=0;
ten_cents1=0;
twinty_cents1=0;
fifty_cents1=0;
one_euro1=0;
two_euros1=0;
% Coins inside the image
for i=1:x
if (v(i)>19 && v(i)<21)
one_cent1=one_cent1+1;
end
if (v(i)>22 && v(i)<24)
two_cents1=two_cents1+1;
end
if (v(i)>24 && v(i)<25)
ten_cents1=ten_cents1+1;
end
if (v(i)>26 && v(i)<27)
five_cents1=five_cents1+1;
end
if (v(i)>27 && v(i)<28)
twenty_cents1=twenty_cents1+1;
end
if (v(i)>28 && v(i)<29)
one_euro1=one_euro1+1;
end
if (v(i)>29 && v(i)<30)
fifty_cents1=fifty_cents1+1;
end
if (v(i)>30 && v(i)<32)
two_euros1=two_euros1+1;
end
tot_obj_center=one_cents1*0.01+two_cents1*0.02+ten_cents1*0.1+five_cents1*0.05+twinty_cents1*0.2+one_euro1*1+fifty_cents1*0.5+two_euros1*2;
end