function O=myconv3(I,mask);
% Perform a convolution of image I with an odd or even sized filter mask
% O=myconv(I,mask)
% theorectically mask should contain the vertically and horizontally
% flipped filter coefficients
% output cropped image

[sy,sx]=size(mask);

I=double(I);
[height,width]=size(I);

for j=1:height-sy+1,
    for i=1:width-sx+1,
        O(j,i)=sum(sum(I(j:j+sy-1,i:i+sx-1).*mask(:,:)));  % convolution operation      
    end
end

