How can i plot the intensity of each row in an image?
Show older comments
This is what I have so far for my code. I was either going to use intensityValue or improfile but I don't really understand how it works.
I = imread('C:\Users\student\Pictures\2017-07-11\image.jpg');
warning('off', 'Images:initSize:adjustingMag');
%intensityValue= I (100,500);
%improfile
imshow(I);
Answers (2)
Prashant Arora
on 17 Jul 2017
Edited: Prashant Arora
on 17 Jul 2017
Hi Amelia,
I am assuming you have a 2-dimensional Image I. You can directly use the value in the image matrix to plot the intensity. For example:
I = imread('liftingbody.png');
x = 1:size(I,1);
y = 1:size(I,2);
[X,Y] = meshgrid(x,y);
plot3(X,Y,I)
5 Comments
Amelia Biase
on 17 Jul 2017
Amelia Biase
on 17 Jul 2017
Edited: Walter Roberson
on 17 Jul 2017
Prashant Arora
on 17 Jul 2017
Amelia, your image seems to be nxmx3 type. You can convert it to gray-scale to compute the "intensity" using Image = rgb2gray(Image);
Walter Roberson
on 17 Jul 2017
Prashant Arora wrote "I am assuming you have a 2-dimensional Image I." . Your image is not 2D. You need to do rgb2gray to get intensity.
AKSHAY KUMAR
on 12 Mar 2019
after using rgb2gray it still shows the same image as that of attached file
Walter Roberson
on 17 Jul 2017
Edited: Walter Roberson
on 17 Jul 2017
surf( rgb2gray(YourRGBImage), 'edgecolor', 'none' )
colormap(gray(256))
12 Comments
Amelia Biase
on 17 Jul 2017
Amelia Biase
on 17 Jul 2017
Edited: Walter Roberson
on 17 Jul 2017
Walter Roberson
on 17 Jul 2017
You can give the command
view(2)
to see it as 2D. However, the result should be the same (except perhaps rotated) as if you had just viewed the grayscale version of the image.
It would be easier for us to assist you in replicating a plot if we had a sample of the desired output.
My speculation is that what you are after is a plot showing either the mean or maximum intensity projection of the rows.
I = imread('C:\Users\student\Pictures\2017-07-11\image.jpg');
grey = rgb2gray(I);
subplot(1,2,1)
meanrowinten = mean(grey, 2);
plot(meanrowinten)
ylabel('mean row intensity')
subplot(1,2,2)
maxrowinten = max(grey, 2);
plot(maxrowinten)
ylabel('maximum row intensity')
Image Analyst
on 17 Jul 2017
"If i change it to grayscale, does that mean the image is now gray, would that affect the intensity profile." <=== Yes. But you have to say what you want. You can either have an RGB image with three separate channels for red, green, and blue, and plot just one of those channels. OR you can convert the whole thing to grayscale with rgb2gray() and plot that, either all lines superimposed, or with a display like surf() or waterfall(). You need to clarify what exactly you'd like if you could get exactly that (so we can stop guessing). So, in a perfect world, what would you like to see or end up with?
Amelia Biase
on 18 Jul 2017
Image Analyst
on 18 Jul 2017
Show your original image that you used to get the mean intensity.
Also, I believe the line should have been
maxrowinten = max(grey, [], 2); % Get max across columns within each row.
Amelia Biase
on 18 Jul 2017
Walter Roberson
on 18 Jul 2017
IA is correct, it should have been
maxrowinten = max(grey, [], 2); % Get max across columns within each row.
Walter Roberson
on 18 Jul 2017
For setups like this, the setup is typically that there is a prism of some sort spreading the light, and that there is a band of monochrome CCD sensors. The position of each sensor is known, and the dispersion is known, so the frequency associated with each sensor is known.
Converting color photographs of color images into accurate intensity for scientific purposes is tricky. You need an accurate ICC color profile of the sensors used to take the photograph, and you have to worry about aliasing: any particular sensor reading might possibly be due to the "naive" interpretation, but it might also be associated with a brighter source being received less efficiently. And you have to take into account the properties of whatever the light is being reflected off of...
Amelia Biase
on 19 Jul 2017
Edited: Walter Roberson
on 19 Jul 2017
Walter Roberson
on 19 Jul 2017
max() and mean() have different calling sequences. max(A, B) is element-by-element max(A(I,J), B(I,J)) unless B is empty, [], in which case max(A, []) is the same as max(A, [], 1) which is per-column maximum. max(A, [], 2) is per-row maximum.
mean(A,1) is per-column mean, and mean(A,2) is per-row mean.
Amelia Biase
on 19 Jul 2017
Edited: Amelia Biase
on 19 Jul 2017
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!