Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Plain Text by gelignite ( 17 years ago )
function convoluted_image = my_own_convolution( matrix, kernel )
%MY_OWN_CONVOLUTION Summary of this function goes here
% Detailed explanation goes here
%
% NOTE: The matrix is expected to be the pure/real image but not already
% an expanded version of it as this function will expand the image,
% too.
%
% Expand image
expanded_image = expand_matrix( matrix, kernel );
% Original image's dimension
i_height = size( matrix, 1 );
i_width = size( matrix, 2 );
% Kernel's dimensions
k_height = size( kernel, 1 );
k_width = size( kernel, 2 );
% Determine offsets
xoffset = floor( k_height / 2 );
yoffset = floor( k_width / 2 );
% Pre-allocate for runtime issues
convoluted_image = zeros( size( matrix ));
% Outer loops traversing the image
for x = (xoffset + 1):i_height
for y = (yoffset + 1):i_width
newVal = 0;
% Inner loops traversing the kernel
for u = 1:k_height
for v = 1:k_width
% Convolute
newVal = newVal + sum( expanded_image( x - xoffset + u , y - yoffset + v) * kernel( u, v ) );
end
end % End of inner for-loops
% Set convoluted value
convoluted_image( x - xoffset, y - yoffset ) = newVal;
end
end % End of outer for-loops
% Display image
figure
colormap([(1:255)', (1:255)', (1:255)']/255);
imagesc( convoluted_image );
end % End of function
Revise this Paste
Parent: 13086
Children: 13090