matlab code
조회 수: 62 (최근 30일)
이전 댓글 표시
clear
clc
d1=120; d2=94;
I =imread('C:\Users\SAMA CENTER\Desktop\girl.jpg');
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
2012년 3월 10일
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.
댓글 수: 2
Chandra Kurniawan
2012년 3월 10일
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);
추가 답변 (1개)
777
2012년 3월 10일
your code has x(2*k1-1) ,so when the value of k1=120 you reach a value which is out of bounds for x.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!