Info

この質問は閉じられています。 編集または回答するには再度開いてください。

why this gives me "Index exceeds matrix dimensions?" can any one help me. Thanks in advance

1 回表示 (過去 30 日間)
Surya Gnyawali
Surya Gnyawali 2016 年 10 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
figure
img = imshow(stretched_CIR);
title('CIR after Decorrelation Stretch');
h = imfreehand;
m = createMask(h, img);
delete(h)
% Extract individual color channels
r = img(:,:,1);
g = img(:,:,2);
b = img(:,:,3);
%Now I evaluate for RGB color channels;
>> r = img(:,:,1);
%works but
>> g = img(:,:,2);
Index exceeds matrix dimensions.
%why?

回答 (3 件)

Matthew Eicholtz
Matthew Eicholtz 2016 年 10 月 5 日
Are you sure the image is RGB instead of grayscale? As the error suggests, the variable img must not have a 2 layer in the 3rd dimension.

Surya Gnyawali
Surya Gnyawali 2016 年 10 月 5 日
The image is attached. Please advise

Guillaume
Guillaume 2016 年 10 月 5 日
The problem is with
img = imshow('...')
As per the documentation of imshow, its return value is a handle to a graphics object, not an image. You need to load the image properly with imread:
img = imread(stretched_CIR);
%and if you want to see the image
imshow(img);

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by