24bit Script
>> % Read in the image in tiff format
>> [r,g,b] = tiffread('img14.tif');
>>
>> % The pixels are in the range of [0,1]
>> max(max(r))
ans =
1
min(min(r))
ans =
0
% The red image plane is two dimensional
>> ndims(r)
>>
ans =
% The red image plane is a 512x768 matrix
>> size(r)
>>
ans =
512 768
>> % Form a three dimensional img array
>> img = cat(3,r,g,b);
>>
>> % The new image is three dimensional
>> ndims(r)
ans =
2
% The new image is 512x768x3
>> size(img)
ans =
512 768 3
% We may display the new 24-bit image
>> image(img)
>> axis('image');
>>
% The pixel at location (400,200) is given by
>> pixel = img(400,200,:)
pixel(:,:,1) =
0.6980
>>
>>
>>pixel(:,:,2) =
0.1294
>>
>>
>>pixel(:,:,3) =
0.1647
>> size(pixel)
>>
ans =
1 1 3
% The pixel may then be converted to a vector
>> pixel = squeeze(pixel)
>>
pixel =
0.6980
0.1294
0.1647
>> size(pixel)
>>
ans =
3 1
>>