Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Index exceeds matrix dimensions.

조회 수: 1 (최근 30일)
Dani D
Dani D 2016년 11월 18일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello, I have an error :( Index exceeds matrix dimensions.
clc;
clear;
close all;
I = imread('C:\Users\Pictures\sgs.jpg');
I = rgb2gray(I);
[m , n ] = size(I);
MaxI = 0;
for i = 1:n
for j = 1:m
if (I(i,j) > MaxI)
MaxI = I(i,j);
end
end
end

답변 (1개)

Adam
Adam 2016년 11월 18일
[m , n ] = size(I);
gives you the number of rows and columns in m and n respectively.
You then loop i up to n and j up to m, but use
I(i,j)
which is switching round the rows with the columns so unless you have a square image you will see this error.

Community Treasure Hunt

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

Start Hunting!

Translated by