Professional Documents
Culture Documents
Appendix: Matlab Codes: File Name: Program1.m
Appendix: Matlab Codes: File Name: Program1.m
Matlab Codes:
% multiplying the filtered image with weight 3 and add the result to the
original image
value=mul(k,filtered_image);
OpImg=add(InImg,value);
% traverse the array and apply the filter inorder to get the sum of all
% pixels. This helps to get the bounderies of various objects in the image
for i = 1:1:row
for j = 1:1:col
img(i,j) = g(i,j)*filter(1,1) + g(i+1,j)*filter(2,1) +
g(i+2,j)*filter(3,1)+ g(i,j+1)*filter(1,2) + g(i+1,j+1)*filter(2,2) +
g(i+2,j+1)*filter(3,2)+ g(i,j+2)*filter(1,3) + g(i+1,j+2)*filter(2,3) +
g(i+2,j+2)*filter(3,3);
end
end
img=im2uint8(img);
end
%--------------------------------------------------------------------------
% Check for right number of parameters
%--------------------------------------------------------------------------
if nargin ~= 2
error('Requires two input arguments addition(image1,image2)');
exit 1
end
output=input1 + input2;
end
%--------------------------------------------------------------------------
% Check for right number of parameters
%--------------------------------------------------------------------------
if nargin ~= 2
error('Requires two input arguments addition(image1,image2)');
exit 1
end
input1=im2double(input1);
input2=im2double(input2);
output=input1 .* input2;
output=im2uint8(output);
end