matlab code

noor

noor (view profile)

님이 질문을 제출함. 10 Mar 2012
Chandra Kurniawan

Chandra Kurniawan (view profile)

님이 답변을 채택함.
clear
clc
d1=120; d2=94;
J = imresize(I,[200 250]);
X = rgb2gray(I);
Y=X';
for k1=1:d1
for k2=1:d2
B(2*k1,k2)=X(k1, k2);
B(2*k1-1,k2)=floor((X(k1,k2)+X(2*k1-1,k2))/2);
end
end
imshow(B);
What's wrong with this code?? there is some wrong with the floor function what is it ???

댓글 수: 2

Chandra Kurniawan

Chandra Kurniawan (view profile)

on 10 Mar 2012
Please show me the error message!
noor

noor (view profile)

on 10 Mar 2012
??? Attempted to access X(213,1); index out of bounds because size(X)=[212,320].
Error in ==> floor at 12
B(2*k1-1,k2)=floor((X(k1,k2)+X(2*k1-1,k2))/2);

로그인 to comment.

답변 수: 2

Answer by Chandra Kurniawan

Chandra Kurniawan (view profile)

on 10 Mar 2012

The error message sounds you accessed X(213,1) while the size of X is 212x320
X is a gray image generated from command : X = rgb2gray(I);
so, the original image I has 212x320 dimension.

noor

noor (view profile)

on 10 Mar 2012
so what can i do ??
Chandra Kurniawan

Chandra Kurniawan (view profile)

on 10 Mar 2012
You wrote the code d1=120 and also wrote B(2*k1,k2)
So, ideally the image must have minimum 2*120 x 94 dimension.
You can resize the image.
J = imresize(I,[240 94]);
Then followed with :
X = rgb2gray(J);

로그인 to comment.