uaci score of 2 images
古いコメントを表示
I need to find the uaci score of two images, one the plain image and other image which is 1 pixel value changed in the plain image. I used the below code and always gets zero. Please help me with the code.
uaci_sum=0; var = 0;
for i=1:256
for j=1:256
var1 = o(i,j);
var2 = oc(i,j);
dif = minus(var1,var2);
diff = abs(dif);
div = diff/255;
uaci_sum = uaci_sum+div;
end
end
uaciscore=(uaci_sum/65536)*100;
Here o and oc are two images and the pixel value change in oc is at (2,8). And also whether there is any problem that the image matrices are of uint8?
回答 (1 件)
Walter Roberson
2017 年 10 月 10 日
Yes, the problem is that they are uint8. Subtracting a larger uint8 from a smaller one always gives 0, not a negative number.
You should replace
dif = minus(var1,var2);
diff = abs(dif);
div = diff/255;
with
div = (max(var1,var2) - min(var1,var2)) / 255;
or with
div = abs(double(var1) - double(var2)) / 255;
6 件のコメント
SNEHA P S
2017 年 10 月 11 日
Walter Roberson
2017 年 10 月 11 日
Your uaci_sum can be calculated without loops as
uaci_sum = sum(sum(abs(double(o(1:256, 1:256) - double(oc(1:256, 1:256))))) / 255;
Or, more simply if o and oc are 256 x 256,
uaci_sum = sum( abs(double(o(:)) - double(oc(:))) ) / 255;
I tested your code with
o = randi([0 255], 256, 256, 'uint8');
oc = o; oc(16142) = 132; %change one pixel
uaci_sum=0; var = 0;
for i=1:256
for j=1:256
var1 = o(i,j);
var2 = oc(i,j);
div = abs(double(var1) - double(var2)) / 255;
uaci_sum = uaci_sum+div;
end
end
uaciscore=(uaci_sum/65536)*100;
the result was non-zero, and the result exactly agreed with
uaci_sum = sum( abs(double(o(:)) - double(oc(:))) ) / 255;
uaciscore=(uaci_sum/65536)*100;
aaru sri
2019 年 5 月 1 日
Here the UACI is 2.333697150735294e-04 so its value means normallyUACI is written as 0.30% then how can we write it in this format
Walter Roberson
2019 年 5 月 1 日
sprintf('%.2f%%', uaciscore * 100)
aaru sri
2019 年 5 月 17 日
Can i use sprintf('%.2f%%', uaciscore * 10000) in my code as my UACIscore is coming as 1.149195374426213e-05
Walter Roberson
2019 年 5 月 17 日
sprintf('%.2f%c', uaciscore * 10000, 8241)
This use the character ‱ https://www.fileformat.info/info/unicode/char/2031/index.htm which is the per-10000 symbol.
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!