im2col
Rearrange image blocks into columns
Syntax
Description
rearranges discrete image blocks of size
B
= im2col(A
,[m n]
,'distinct')m
-by-n
into columns, and returns the
concatenated columns in matrix B
. The im2col
function pads image A
, if necessary. For more information about
the padding value, see Tips.
The order of the columns in matrix B
is determined by
traversing the image A
in a column-wise manner. For example, if
A
consists of distinct blocks Aij
arranged as A = [A11 A12; A21 A22]
, then B = [A11(:)
A21(:) A12(:) A22(:)]
.
Examples
Input Arguments
Output Arguments
Tips
For distinct block processing,
im2col
zero-padsA
, if necessary, so its size is an integer multiple ofm
-by-n
. The padding value is0
whenA
is data typeuint8
,uint16
, orlogical
. For other data types, the value of padding depends on whetherA
is interpreted as an indexed image.The padding value is
1
whenA
is interpreted as an indexed image.The padding value is
0
whenA
is not interpreted as an indexed image.
im2col
orders the columns ofB
so that they can be reshaped to form a matrix according toreshape
.For example, suppose you use a function, such as
sum(B)
, that returns a scalar for each column ofB
. You can directly store the result in a matrix of size (mm-m+1
)-by-(nn-n+1
), using these calls.B = im2col(A,[m n],'sliding'); C = reshape(sum(B),mm-m+1,nn-n+1);
Version History
Introduced before R2006a