Reputation: 175
I'm trying to calculate the CIR(standard color-infrared) of an Image using the function multibandread but give me an error. I'm trying this tutorial of mathworks: Mathworks
The image is 500x500x3 uint8. This is my code:
G = imread ('nir.tif');
if size(G,3) == 4 %alpha
G = G(:,:,1:3); %strip alpha
end
CIR = multibandread(G, [500, 500, 4], 'uint8=>uint8',...
128, 'bil', 'ieee-le', {'Band','Direct',[4 3 2]});
figure
imshow(CIR);
This is the error: Index exceeds matrix dimensions.
Upvotes: 1
Views: 261
Reputation: 1164
You did not mention in which line the error occurs but it seems like there is a problem about size parameter of multibandread
function.
First, you have limited number of bands of the image to 3, then tried to read 4 bands from image.
Your problem may be solved with following change:
CIR = multibandread(G, [500, 500, 3], 'uint8=>uint8',...
128, 'bil', 'ieee-le', {'Band','Direct',[3 2 1]});
Moreover, the first parameter of multibandread
, filename, should be in string, not a matrix.
Upvotes: 1