Hello, I am new to Matlab and I have a question concerning getting pixel values of an image. I have a 994x994 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

 채택된 답변

Thorsten
Thorsten 2016년 7월 22일
편집: Thorsten 2016년 7월 22일

2 개 추천

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, :);

댓글 수: 3

Gannian Zhang
Gannian Zhang 2016년 7월 22일
Thank you very much for your reply.
Could you please expand a little on your answer as I do not get what you say here? Thank you very much.
Regards
Thorsten
Thorsten 2016년 7월 22일
I've updated my response.
Gannian Zhang
Gannian Zhang 2016년 7월 24일
Hi Thanks so much for the explanation. I have finally solved this problem. :-)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 22일

2 개 추천

You can use imread to import your image like this
Im=imread('YourImage.tif') % for example
row497=Im(497,:,:)
You can export your image to an excel file
xlswrite('file.xlsx',Im)

댓글 수: 4

Gannian Zhang
Gannian Zhang 2016년 7월 22일
편집: Azzi Abdelmalek 2016년 7월 22일
Thank you very much for your reply.
I see. Now I get the idea. If I may, I wish to ask another quick question about using the 'imread' command. Here is what I did following your advice.
RGB = imread('image.tif');
I = rgb2gray(RGB);
Greyimage = imread(I); (But the command here did not work);
Also could you please tell me how I could do this:
row497 = Greyimage(497,i);
I wish to ask Matlab to export all the data from i=1 to i=997.
Thanks again for your kind help.
Regards
Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 22일
What is the aim of this: Greyimage = imread(I) ? I is not a file, it's already a matrix representing an image.
Gannian Zhang
Gannian Zhang 2016년 7월 24일
Hi, thanks for your reply.
The original image was a coloured one which had three channels showing different pixel values. I wanted to convert it into a grey image first before analysis.
Could you please let me know how to do that? And how can I export data from i=1 to i=997 please? Regards.
Gannian Zhang
Gannian Zhang 2016년 7월 24일
Hi Thank you for your help. I have finally solved the problem.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

질문:

2016년 7월 22일

댓글:

2016년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by