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!