# How can i extract numerical intensity values from an image

12 ビュー (過去 30 日間)
Joshua Ray 2019 年 5 月 20 日
Answered: Rik 2019 年 5 月 20 日
Consider an image sample.jpg Now I want to extract numerical value of pixel intensity for every pixel and the pixel location on the X and y axis such that I will have three columns X location y location and their corresponding pixel intensity. Please can someone help me with a code or a direction on how I can accomplish this?

#### 0 件のコメント

サインイン to comment.

### 採用された回答

Rik 2019 年 5 月 20 日
You can make use of the fact that an image is already a matrix. Instead of ndgrid (as used in this code), you could also consider using fullfact (although that requires the statistics toolbox).
%generate a random image to make this code run
IM=uint8(randi(255,10,5));
%note that the convention is to have the y-axis flipped in images
[Y,X]=ndgrid(1:size(IM,1),size(IM,2):-1:1);
%convert the intensity to double to make sure the entire table is a double,
%which allows x and y to be greater than 255
data=[X(:),Y(:),double(IM(:))];

#### 0 件のコメント

サインイン to comment.