Attempted to access G(2305,1,3); index out of bounds because size(G)=[2304,4096,3

2 vues (au cours des 30 derniers jours)
Muhammad Amin Almuhyi
Muhammad Amin Almuhyi le 24 Juin 2021
Réponse apportée : KSSV le 24 Juin 2021
can you plese solve this
clear all;
imfinfo('C:\Users\LENOVO\Downloads\IMG_20210623_171757.jpg');
G=imread('C:\Users\LENOVO\Downloads\IMG_20210623_171757.jpg');
figure(1)
imshow(G)
axis on;
f=0,06430379746835442;
l=4096;dx=1;%Lebar(arah sumbu x)
t=2304;dy=1;%Tinggi(arah sumbu y)
z=1;
for x=-l:dx:l;
j=1;
for y=-t:dy:t;
E=G(y+2305,x+4097,3);
nilai(z,j)=E;
j=j+1;
end
z=z+1;
end
i am getting error command Attempted to access G(2305,1,3); index out of bounds because size(G)=[2304,4096,3
Attempted to access G(2305,1,3); index out of bounds because size(G)=[2304,4096,3].
Error in Untitled2 (line 14)
E=G(y+2305,x+4097,3);

Réponses (1)

KSSV
KSSV le 24 Juin 2021
You see the error is clear. You are trying to extracting more number of elements than present in the matrix.
Example:
A = rand(5) ; % A is of size 5x5
A(1,5) % no error, element exists
A(5,5) % no error, element exists
A(5,6) % error as the element is not present
Similiarly G is of size [2304,4096,3]. You are trying to extract G(2305,1,3) which is not present.
You need to check your loop indices.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by