Image convolution: Difference between revisions

m
→‎{{header|MATLAB}}: Fixed typo (kernal → kernel)
m (→‎{{header|MATLAB}}: Fixed typo (kernal → kernel))
Line 1,236:
fprintf('Original image:\n')
disp(Im)
fprintf('Original kernalkernel:\n')
disp(Ker)
fprintf('Padding with zeroes:\n')
Line 1,244:
fprintf('Duplicating border pixels to pad image:\n')
disp(convImage(Im, Ker, 'extend'))
fprintf('Renormalizing kernalkernel and using only values within image:\n')
disp(convImage(Im, Ker, 'partial'))
fprintf('Only processing inner (non-border) pixels:\n')
Line 1,266:
% figure
% imshow(imresize(convImage(Im, Ker, 'partial'), 10))
% title('Renormalizing kernalkernel and using only values within image')
% figure
% imshow(imresize(convImage(Im, Ker, 'none'), 10))
Line 1,274:
function ImOut = convImage(Im, Ker, varargin)
% ImOut = convImage(Im, Ker)
% Filters an image using sliding-window kernalkernel convolution.
% Convolution is done layer-by-layer. Use rgb2gray if single-layer needed.
% Zero-padding convolution will be used if no border handling is specified.
Line 1,287:
% ImOut = convImage(Im, Ker, 'value', padVal)
% Image will be padded with padVal when calculating convolution
% (possibly useful for emphasizing certain data with unusual kernalkernel)
%
% ImOut = convImage(Im, Ker, 'extend')
Line 1,401:
1 1 1 1 1
 
Original kernalkernel:
1 2 1
2 4 2
Line 1,427:
29 23 20 20 20
 
Renormalizing kernalkernel and using only values within image:
21.3333 32.0000 57.3333 88.0000 101.3333
36.0000 50.0000 79.0000 104.0000 112.0000
Anonymous user