Pixel value difference histogram of two images
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Suppose I have two matrices for cover and stego images. I want to draw the pixel value difference histogram as shown in the above figure. I am facing problem in setting edges. I need the x-label as [-20 -15 -10 -5 0 5 10 15 20] as shown in the above figure. I could not able to show the Legents as the above figure. Please help me.....
edges = [-20 -5:0:5 20];
histogram(cover,edges,'DisplayStyle','stairs');
hold on;
histogram(stego,edges,'DisplayStyle','stairs');
legend('Cover Image');
legend('Stego Image');
0 commentaires
Réponses (1)
Darshak
le 3 Mar 2025
From the image you have provided, the plot you are looking for is for the centre of histogram bins not the histogram itself, due to which you are not getting the expected plot and the legend. You can use the code given below to do calculate the bin centers and plot them to generate the plot shown as in the given image:
edges = [-20, -15, -10, -5, 0, 5, 10, 15, 20];
% Calculate histogram data manually
[coverCounts, ~] = histcounts(cover, edges);
[stegoCounts, ~] = histcounts(stego, edges);
% Calculate bin centers
binCenters = (edges(1:end-1) + edges(2:end)) / 2;
plot(binCenters, coverCounts, 'ro-', 'MarkerFaceColor', 'r');
hold on;
plot(binCenters, stegoCounts, 'bs-', 'MarkerFaceColor', 'b');
legend('Cover Image', 'Stego Image');
xticks(edges);
xlabel('Prediction Error');
ylabel('Frequency');
hold off;
You can explore the “plot” function in the given documentation page – https://www.mathworks.com/help/releases/R2021a/matlab/ref/plot.html
0 commentaires
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!