Percentage of white pixel
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)) / in开发者_运维问答t2str(nnz(Img1))) * 100;
but it returns as result ]
What's the problem ?
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);
精彩评论