|
"Eric " <ethorhauer@gmail.com> wrote in message <hdd7l5$p8q$1@fred.mathworks.com>...
> Hello, I am new to Matlab and trying to learn as much as I can.
>
> I've imported a multiframe TIFF image using the imread command and now have a 3 dimensional matrix. I'm looking for the most efficient/easiest way to reorganize this M by N by P matrix into a 4-column matrix where columns 1,2,3 are the M, N, P coordinates of values (the pixel locations) within the array and column 4 is the value (in this case grayscale value of the image) at that given pixel.
>
> Thank you for your time and any insight you can provide to me.
>
> Best,
>
> Eric
% Load image
image = imread('image.tif');
% Reshape as each layer column vector
M = reshape(image(:,:,1),numel(image(:,:,1)),1);
N = reshape(image(:,:,2),numel(image(:,:,1)),1);
P = reshape(image(:,:,3),numel(image(:,:,1)),1);
% concatenate
final =[M N P];
Try this. You might shorten this code further - Naresh
|