Is there a way to calculate differnce between two pictures and show it as %?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have following code that use hamming code on pictures and I want to have a clear indication on how much better my decoded picture is.
I know how to calculate mse but i need to calculate difference in pixels or %
i also added the code and image i use if you need to recreate my problem
best regards
0 Kommentare
Antworten (2)
Prasanna
am 26 Mär. 2024
Hi,
To calculate the difference in pixels or the percentage improvement in image quality after applying the Hamming code for error correction, you can use the following approach. This involves calculating the number of pixels that are different between the original and the noisy images, and then between the original and the decoded images. You can then express the improvement as a percentage reduction in the number of differing pixels. The following script calculates the percentage of pixels that are different between the original image and the noisy image, and between the original image and the decoded image.
% Calculate the number of differing pixels between the original and noisy images
diff_pixels_noisy = sum(img(:) ~= noisy_img(:));
% Calculate the number of differing pixels between the original and decoded images
diff_pixels_decoded = sum(img(:) ~= decoded_noisy_img_norm(:));
% Calculate the total number of pixels in the image
total_pixels = numel(img);
% Calculate the percentage of differing pixels for both cases
percentage_diff_noisy = (diff_pixels_noisy / total_pixels) * 100;
percentage_diff_decoded = (diff_pixels_decoded / total_pixels) * 100;
fprintf('Percentage of differing pixels (noisy image): %.2f%%\n', percentage_diff_noisy);
fprintf('Percentage of differing pixels (decoded image): %.2f%%\n', percentage_diff_decoded);
1 Kommentar
DGM
am 26 Mär. 2024
Why use the number of unequal pixels as a measure of quality? I get that OP mentioned "pixels", but I don't think that's what was intended. It's not going to tell you much about the magnitude of the error, just its distribution. If you'd tested your code, you'd see that it indicates that the visibly clearer error-corrected image is worse. In other words, it's providing the user with directly misleading information.
percentage_diff_noisy =
49.7329
percentage_diff_decoded =
74.3763
The original code was already using MSE, so why not use that?
relative_error = error_after_Hamming/error_without_Hamming * 100
error_reduction = 100 - relative_error
relative_error =
32.3552
error_reduction =
67.6448
That clearly tells the user that the image is improved.
Siehe auch
Kategorien
Mehr zu Hamming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!