plotting intensity distributions on an image
Mostrar comentarios más antiguos
I have an image and i can calculate sum of intensities along x and y axis using following code. i want to plot the sum of intensities as histograms on the image along x and y axis, like the example attached. Many thanks for the help
X1=imread('image.png');
intensity_x=sum(X1); %row vector containing the sum of each column.
intensity_y=sum(X1,2); %column vector containing the sum of each row.
4 comentarios
Ameer Hamza
el 12 de Nov. de 2020
Can you show an example?
Sumera Yamin
el 12 de Nov. de 2020
KALYAN ACHARJYA
el 13 de Nov. de 2020
Hello Sumera, still the question is not clear, as the text descriptions of thr questions, it may be-
X1=imread('image.png');
intensity_x=sum(X1); %row vector containing the sum of each column.
intensity_y=sum(X1'); %column vector containing the sum of each row.
plot(intensity_x,intensity_y);
or Are you looking for intensity surf plot, as below?

Please describe the question clearly with an example of 3x3 matrix?
Sumera Yamin
el 13 de Nov. de 2020
Editada: Sumera Yamin
el 13 de Nov. de 2020
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 13 de Nov. de 2020
I gave you an answer here in this link
What I've done in this case is to have two additional axes, one on the left of the image axes, and one below or above it. I plot the vertical profile along the one on the left, with x and y switched, and the horizontal profile along the axes underneath the image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels == 3
grayImage = rgb2gray(grayImage);
end
verticalSum = sum(grayImage, 2);
horizontalSum = sum(grayImage, 1);
axes(handles.axesLeft); % Switch to the axes to the left of the image axes.
plot(verticalSum, 1:rows, 'b-', 'LineWidth', 2);
grid on;
axes(handles.axesBelow); % Switch to the axes below the image axes.
plot(1 : columns, horizontalSum, 'b-', 'LineWidth', 2);
grid on;
3 comentarios
Sumera Yamin
el 13 de Nov. de 2020
Editada: Sumera Yamin
el 13 de Nov. de 2020
Image Analyst
el 13 de Nov. de 2020
I guess you're not using a GUIDE GUI. Just replace handles.axesLeft with whatever the handles to those axes are. Not the main image axes, but the two additional ones you set up beside it to show the profiles.
Sumera Yamin
el 13 de Nov. de 2020
Categorías
Más información sobre Printing and Saving en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
