tags:

views:

24

answers:

1

After performing processing I want to calculate the percentage of white pixels between this images after the change.

I'm doing this: var = (int2str(nnz(Img2)) / int2str(nnz(Img1))) * 100;

but it returns as result ]

What's the problem ?

+1  A: 

The function INT2STR is only needed to convert an integer value to a string (usually for the purpose of displaying it). If you just want the numerical value, leave that out:

var = 100*nnz(Img2)/nnz(Img1);

If you now want to turn var into a string value, you can use NUM2STR (since var is likely not going to be an integer value any more):

varString = num2str(var);
gnovice
It's giving me: Warning: Out of range or non-integer values truncated during conversionto character.When I use it in this case : title(['Percentage : ' 100 * nnz(Img4) / nnz(image) ]);
dotNET
@AZIRAR: First, you need to do `num2str(100 * nnz(Img4) / nnz(image))` to convert the number to a string. Second, I would avoid using `image` as a variable name, since there is already a built-in function called IMAGE.
gnovice
Thanks it's working.
dotNET

related questions