How can i extract numerical intensity values from an image

11 次查看(过去 30 天)
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?

采纳的回答

Rik
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 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by