How to plot a graph of a line of pixels of an image showing black to white intensity across it.

Hi, I am completely new to Matlab and quickly need to use it to analyse an image I have. The image is black and white from a photo of 256 by 256 pixels and contains a beam. I would like to be able to specify a line of pixels across the image and plot a graph of the variation of white to black as I go along these pixels which should show a curve where my black beam is on a white(ish) background.
This image is obtained from a fourier transform (fft1) which makes the image greyscale (I think). I was told that typing 'plot(fft1(1,1:255))' is a good place to start from but it doesn't seem to plot a useful curve.
I have been told this is easy to do although I haven't found any relevant information, Any help would be much appreciated! Thanks, Graham

 Accepted Answer

If you have the Image Processing Toolbox, have a look at improfile.

3 Comments

Great thanks, this seems to be exactly what I need. Sorry to be a pain (I'm not familiar with the mathematics behind these functions) but I am a little unsure how to specify the coordinates using the c=improfile(I,xi,yi) function. I can use the c=improfile(n) function and pick a line but its not precise. Also, when I use 'plot (c)' it plots the graph onto my image so is there a little trick to making the plot onto a new graph? Thanks again and sorry if these questions are a little basic! Graham
To plot in a ne graph, open a new figure at first: "figure; plot(1:10);".
Excellent thanks, I see how to use the figure and plot functions - Now I just need to figure out how to use the co-ordinates for the improfile function. I trust that I is the image I want to use, xi and yi seem to be vectors but if I want to plot a line from my image of co-ordinates say...(1,30) to (50,30) how would this translate to the xi and yi required for the function?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!