Home > freetb4matlab > image > im2col.m



% Rearranges image blocks into columns.


function B = im2col(A, varargin)


% -*- texinfo -*-
% @deftypefn {Function File} {@var{B} = } im2col (@var{A}, [@var{m},@var{n}], @var{block_type})
% @deftypefnx {Function File} {@var{B} = } im2col (@var{A}, [@var{m},@var{n}])
% @deftypefnx {Function File} {@var{B} = } im2col (@var{A}, 'indexed', ...)
% Rearranges image blocks into columns.
% @code{B=im2col(A, [m, n], blocktype)} rearranges blocks in @var{A}
% into columns in a way that's determined by @var{block_type}, which
% can take the following values:
% @table @code
% @item distinct
% Rearranges each distinct @var{m}-by-@var{n} block in image @var{A}
% into a column of @var{B}. Blocks are scanned from left to right and
% the up to bottom in @var{A}, and columns are added to @var{B} from
% left to right. If @var{A}'s size is not multiple @var{m}-by-@var{n}
% it is padded.
% @item sliding
% Rearranges any @var{m}-by-@var{n} sliding block of @var{A} in a
% column of @var{B}, without any padding, so only sliding blocks which
% can be built using a full @var{m}-by-@var{n} neighbourhood are taken.
% In consequence, @var{B} has @var{m}*@var{n} rows and
% (@var{mm}-@var{m}+1)*(@var{nn}-@var{n}+1) columns (where @var{mm} and
% @var{nn} are the size of @var{A}).
% This case is thought to be used applying operations on columns of
% @var{B} (for instance using sum(:)), so that result is a
% 1-by-(@var{mm}-@var{m}+1)*(@var{nn}-@var{n}+1) vector, that is what
% the complementary function @code{col2im} expects.
% @end table
% @code{B=im2col(A,[m,n])} takes @code{distinct} as a default value for
% @var{block_type}. 
% @code{B=im2col(A,'indexed',...)} will treat @var{A} as an indexed
% image, so it will pad using 1 if @var{A} is double. All other cases
% (incluing indexed matrices with uint8 and uint16 types and
% non-indexed images) will use 0 as padding value.
% Any padding needed in 'distinct' processing will be added at right
% and bottom edges of the image.
% @seealso{col2im}
% @end deftypefn


This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003