MATLAB: Getting pixel values from an image

pixel values

Hello, I am new to Matlab and I have a question concerning getting pixel values of an image. I have a 994×994 image and want to get every pixel value in the row 497. Could you please advise what command(s) I should use? Thank you very much.
I have loaded the image in Matlab with Imtool command and there is a pixel region window in which it shows all the pixel values I need. I am wondering if I could export them in an excel file? Thanks again.
Regards

Best Answer

If your image is stored in I, like from the command
I = imread('peppers.png');
the Matlab syntax to select the element in row 497, column 1 would be
x = I(497,1);
and the syntax to select all elements uses the column operator : as a shorthand for 1:end
x = I(497, :);