Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how convert gray image to n-by-3 array

Tags:

matlab

Hi I use imread for gray image reading. It gives me a x-by-y matrix (contains gray level in every cells) but i need it in n-by-3 (x,y, and gray level) array of image points.
How i can convert imread result to n-by-3 array.

Thanks

like image 882
bartek Avatar asked Dec 02 '25 04:12

bartek


1 Answers

[height, width] = size(image);
[X, Y] = meshgrid(1:width, 1:height);
points = [X(:) Y(:) image(:)]
like image 67
rwong Avatar answered Dec 08 '25 20:12

rwong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!