Dimension problem with Kirsch oprerator.

2 views (last 30 days)
I just can't find the collision between formats in my vectors.Here's the code, basic kirsch operator in which I get error
"??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts" in the for loop
function ks = Kirsch(A)
A = imread(A);
A = im2double(A);
m = zeros(3,3,8);
m(:,:,1) = [-3 -3 5; -3 0 5; -3 -3 5];
m(:,:,2) = [-3 5 5; -3 0 5; -3 -3 -3];
m(:,:,3) = [5 5 5; -3 0 -3; -3 -3 -3];
m(:,:,4) = [5 5 -3; 5 0 -3; -3 -3 -3];
m(:,:,5) = [5 -3 -3; 5 0 -3; 5 -3 -3];
m(:,:,6) = [-3 -3 -3; 5 0 -3; 5 5 -3];
m(:,:,7) = [-3 -3 -3; -3 0 -3; 5 5 5];
m(:,:,8) = [-3 -3 -3; -3 0 5; -3 5 5];
Am=zeros(size(A,1), size(A,2),8);
for i=1:8
Am(:,:,i) = imfilter(A,m(:,:,i));
end
Ak = max(Am,[],3);
n = 255 / (max(Ak(:)) - min(Ak(:)));
pic = uint8(n * Ak);
figure, imshow(pic);
*********************************************************************************
error is in for loop where Am(:,:,i) = imfilter(A,m(:,:,i));
Please help, im looking into code for several hours, ive tried several source images, for loops etc, but error ist still here
Tomislav

Accepted Answer

Matt J
Matt J on 30 Nov 2012
Edited: Matt J on 30 Nov 2012
A=rgb2gray(A);
Am(:,:,i) = imfilter(A,m(:,:,i),'same')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!