Is there a way to calculate differnce between two pictures and show it as %?

5 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

Prasanna
Prasanna il 26 Mar 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 Commento
DGM
DGM il 26 Mar 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.

Accedi per commentare.


Image Analyst
Image Analyst il 26 Mar 2024

Prodotti


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by