How to plot RGB histogram of an image into a single 3D slice plot?
Hello. Im working on color image encryption and need to plot the histogram for each color channels. I can plot the individual color channel histogram in three 2D plot with this code.
close all;
image = imread(‘peppers.png’);
R = image(:,:,1);
G = image(:,:,2);
B = image(:,:,3);
[Width,Length] = size(image);
subplot(2,2,1); imshow(image);
title(‘Plain Image’)
subplot(2,2,2);
imhist(R);
myHist1 = findobj(gca, ‘Type’, ‘Stem’);
myHist1.Color = [1 0 0];
title(‘Red Channel Plain Histogram’)
subplot(2,2,3);
imhist(G);
myHist2 = findobj(gca, ‘Type’, ‘Stem’);
myHist2.Color = [0 1 0];
title(‘Green Channel Plain Histogram’)
subplot(2,2,4);
imhist(B);
myHist3 = findobj(gca, ‘Type’, ‘Stem’);
myHist3.Color = [0 0 1];
xlim([0 256]);
title(‘Blue Channel Plain Histogram’)
But, i tried to plot them together in a 3D plot like this below (picture from an article i found), but i cant. I tried to find any forum that talks about this, but i can only found slice plots of meshgrid, not from histogram.
If anyone could help, I would appreciate it so much.
Thank you!Hello. Im working on color image encryption and need to plot the histogram for each color channels. I can plot the individual color channel histogram in three 2D plot with this code.
close all;
image = imread(‘peppers.png’);
R = image(:,:,1);
G = image(:,:,2);
B = image(:,:,3);
[Width,Length] = size(image);
subplot(2,2,1); imshow(image);
title(‘Plain Image’)
subplot(2,2,2);
imhist(R);
myHist1 = findobj(gca, ‘Type’, ‘Stem’);
myHist1.Color = [1 0 0];
title(‘Red Channel Plain Histogram’)
subplot(2,2,3);
imhist(G);
myHist2 = findobj(gca, ‘Type’, ‘Stem’);
myHist2.Color = [0 1 0];
title(‘Green Channel Plain Histogram’)
subplot(2,2,4);
imhist(B);
myHist3 = findobj(gca, ‘Type’, ‘Stem’);
myHist3.Color = [0 0 1];
xlim([0 256]);
title(‘Blue Channel Plain Histogram’)
But, i tried to plot them together in a 3D plot like this below (picture from an article i found), but i cant. I tried to find any forum that talks about this, but i can only found slice plots of meshgrid, not from histogram.
If anyone could help, I would appreciate it so much.
Thank you! Hello. Im working on color image encryption and need to plot the histogram for each color channels. I can plot the individual color channel histogram in three 2D plot with this code.
close all;
image = imread(‘peppers.png’);
R = image(:,:,1);
G = image(:,:,2);
B = image(:,:,3);
[Width,Length] = size(image);
subplot(2,2,1); imshow(image);
title(‘Plain Image’)
subplot(2,2,2);
imhist(R);
myHist1 = findobj(gca, ‘Type’, ‘Stem’);
myHist1.Color = [1 0 0];
title(‘Red Channel Plain Histogram’)
subplot(2,2,3);
imhist(G);
myHist2 = findobj(gca, ‘Type’, ‘Stem’);
myHist2.Color = [0 1 0];
title(‘Green Channel Plain Histogram’)
subplot(2,2,4);
imhist(B);
myHist3 = findobj(gca, ‘Type’, ‘Stem’);
myHist3.Color = [0 0 1];
xlim([0 256]);
title(‘Blue Channel Plain Histogram’)
But, i tried to plot them together in a 3D plot like this below (picture from an article i found), but i cant. I tried to find any forum that talks about this, but i can only found slice plots of meshgrid, not from histogram.
If anyone could help, I would appreciate it so much.
Thank you! image processing, histogram, 3d plots MATLAB Answers — New Questions