简体   繁体   中英

How can I draw/plot intensity of image in 2D figure in MATLAB

I have a example about drawing image intensity of image in 2D figure. The y-axis is very clear which is intensity of pixel in the image. However, I am confusing about x-axis, which is pixel index or something? Could you see the figure below and let predict what is x-axis? How can I plot the figure look like that in MATLAB? Thanks

In my knowledge, if x-axis is pixel index then I plot as

I=Img(:);
plot(1:length(I),I);

在此处输入图片说明

Your image is a 2D array that contains, in every element, the pixel intensity.

If you check the image size by size(img) , or if you count the pixels of one row or column of the image on the left, you'll notice that the image is an array of 130x130 pixels.

Consequently, the plots on the right show the intensity profile along one row or column of your image, for example row #100.

To plot row #100, you would write:

plot(img(100,:)) %//Matlab will automatically put x as 1:size(img,2)

To create the figure (top row), you would write

figure
subplot(1,2,1)
imshow(img,[]);
subplot(1,2,2)
plot(img(100,:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM