Pixel value (intensity) vs Pixel position from a 2D graph (TIF) [also known as: profile, extraction, projection] for spectroscopy

5 views (last 30 days)
So I'm doing spectroscopy data reduction, the only issue I'm having is getting a graph of the intensity vs pixel position. I can do it in different programs, but I'm trying to do it in Matlab, example for what I want to do is in the picture below. I just want to select a certain area of the tif image and get the corresponding 2d graph of intensity vs position. I tried using improfile, it gives me a 3d graph (I'm not sure why) also tried impixel which tells me the value of each single pixel but its not what I want.
any help or suggestions are appreciated. Thanks

Answers (1)

Image Analyst
Image Analyst on 15 Nov 2015
I don't see any 2D or 3D graphs. Of course the image itself is a 2D representation of the values, but you're showing it as an image, not as a surface plot, which is fine. The Profile graph you show is a 1D signal. I'm not sure if it's the sum of the columns in between the two rows with lines over them, or if it's along the slanted intensity feature. Anyway, you can use improfile() to get a 1-D intensity profile along a line between two endpoints that you specify. If you want to sum the image vertically between row1 and row2, you can do
horizontalProfile = sum(grayImage(row1:row2,:), 1);
  2 Comments
Ahmed Elshafiey
Ahmed Elshafiey on 15 Nov 2015
So the rectangle I have selected above have 2 axis, x which is just the pixel position, y is the pixel intensity = the summation of the columns between delta x (x1-x2). Thats what I get when I use improfile and select a certain rectangle. (image below) So I want to get the profile for a rectangular area not a line, can you give me an example on how to do that using sum?
Image Analyst
Image Analyst on 15 Nov 2015
I don't understand your explanation or terminology. You say "x which is just the pixel position, y is the pixel intensity" but when I look in the box in the left image above in your original question, x is the column, and y is the row, not the intensity. The intensity is the brightness of the image.
Please post your original image, without the box around it.
When I suggested you use improfile, I did not mean to do it four times around the edges of the bounding box, which is what it looks like you did in your comment. I meant for you to do it once, along the stick-like feature in your image, so the line will be going along that slanted bright thing, not along the bounding box.
Then you ask "I want to get the profile for a rectangular area not a line, can you give me an example on how to do that using sum?" Well, I gave that already. Here it is:
horizontalProfile = sum(grayImage(row1:row2,:), 1);
You need to determine what the top and bottom rows of your bounding box are and just run that line of code and plot it:
plot(horizontalProfile, 'b-', 'LineWidth', 2);
Not that that is the profile horizontally, which may look different than the profile along the slant which you get with improfile().

Sign in to comment.

Categories

Find more on Particle & Nuclear Physics 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!