I need to plot the Intensities in an image as a surface plot.

15 Ansichten (letzte 30 Tage)
Aditya
Aditya am 15 Dez. 2015
Kommentiert: Ayush singhal am 21 Mai 2021
I need to plot the Intensities in an image as a surface plot. The surface plot must have the x values, y values and the intensity at every (x,y).

Antworten (2)

Star Strider
Star Strider am 17 Dez. 2015
I am not certain what you mean by ‘intensity’, but this is one possibility for you to experiment with:
Pprs3 = imread('peppers.png'); % Colour Image
Pprs1 = rgb2gray(Pprs3); % Grayscale Image
x = 0:size(Pprs1,2)-1;
y = 0:size(Pprs1,1)-1;
[X,Y] = meshgrid(x,y); % Coordinate Matrices (Not Necessary)
figure(1)
meshc(X, Y, Pprs1) % Mesh Plot
grid on
xlabel('X')
ylabel('Y')
zlabel('Intensity')
colormap(jet) % Set ‘colormap’
The code first reads the image as RGB (3D) matrix of uint8 values, then converts it to a grayscale matrix of uint8 values. It then creates appropriate coordinate matrices (not necessary, but the plots look better with them), and plots them using the meshc function and the jet colormap. You can also use surf (or surfc) and other colormaps.
Experiment with this code and your image to get the result you want.
  4 Kommentare
Star Strider
Star Strider am 12 Okt. 2020
Ayushman Sengar —
It continues to work correctly for me (as posted) in R2020b.
The problem is not my posted code.
Ayush singhal
Ayush singhal am 21 Mai 2021
hello, I need a small help regarding this.
I have two images like this.(attached). Now I would like to extract the object information from these two images. And show the final images with a surface plot.
could you give some hint about this?

Melden Sie sich an, um zu kommentieren.


Krishnan Ramkumar
Krishnan Ramkumar am 17 Dez. 2015
Hi Aditya,
Generally 'surf' command is used to plot as a surface plot. Is there any issue that you faced while trying to use 'surf' command to plot the intensities in an image as a surface plot.
Regards, Krishnan

Community Treasure Hunt

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

Start Hunting!

Translated by