How can i extract numerical intensity values from an image

6 ビュー (過去 30 日間)
Joshua Ray
Joshua Ray 2019 年 5 月 20 日
回答済み: 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?

採用された回答

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 Center および File ExchangeImages についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by