Horizontal average on Image
이전 댓글 표시
Given that the mask is hor = 0 0 0, 1 1 1, 0 0 0
I have to apply to my image. Afterwards, find the sum and divide by 3.
My code is:
clear; % Clear the workspace
A = imread('Nature.jpg');
I = imrotate(A,90,'bilinear','loose');
grey = 0.21*I(:,:,1)+0.72*I(:,:,2)+0.07*I(:,:,3);
Grey = double(grey);
HorMask = [0 0 0;1 1 1;0 0 0];
[r,c] = size(Grey);
OUT = zeros(r-3,c-3);
for i = 1:(r-3)
for j = 1:(c-3)
GreySquare = Grey(i:(i+2),j:(j+2));
res = HorMask.*GreySquare;
Divide = res./3;
OUT(i,j) = sum(Divide);
end
end
figure()
imshow(OUT);
However, I am not able to divide by 3. with error message:
Subscripted assignment dimension mismatch.
Error in HorizontalAverage (line 16)
OUT(i,j) = sum(Divide);
댓글 수: 1
Jan
2017년 10월 6일
"I am not able" does not explain, what the problem is. Do you get an error message? If so, please post it completely. It is much easier to solve a problem than to guess, what the problem is.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!