Main Content

col2im

Rearrange matrix columns into blocks

Description

A= col2im(B,[m n],[M N])or

A= col2im(B,[m n],[M N],'sliding')rearranges the row vectorBinto neighborhoods of sizem-by-nto create the matrixAof size(M-m+1)-by-(N-n+1).

The row vectorBis usually the result of processing the output ofim2col(...,'sliding')using a column compression function, such assum.

example

A= col2im(B,[m n],[M N],'distinct')rearranges each column of matrixBinto a distinctm-by-nblock to create the matrixAof sizeM-by-N.

For example, ifBconsists of column vectorsBi(:)with lengthm*n, arranged asB = [B1(:) B2(:) B3(:) B4(:)], thenA = [B1 B3; B2 B4]where each blockBihas sizem-by-n.

Examples

collapse all

Create a matrix.

B = reshape(uint8(1:25),[5 5])'
B =5x5 uint8 matrix1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Rearrange the values in the matrix into a column-wise arrangement.

C = im2col(B,[1 5])
C =5x5 uint8 matrix1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25

Rearrange the values in the matrix back into their original row-wise orientation.

A = col2im(C,[1 5],[5 5],'distinct')
A =5x5 uint8 matrix1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Input Arguments

collapse all

Image blocks, specified as one of the following.

  • 对于不同的块处理,Bis a numeric or logical matrix withm*nrows. Each column corresponds to one block.

  • For sliding neighborhood processing,Bis a numeric or logical row vector of size 1-by-(M-m+1)*(N-n+1).

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|logical

Block size, specified as a 2-element vector of positive integers.mis the number of rows andnis the number of columns in each block.m*nmust be equal to the number of rows ofB.

Data Types:double

Image size, specified as a 2-element vector of positive integers.Mis the number of rows andNis the number of columns in the image.

Data Types:double

Output Arguments

collapse all

Reconstructed image, returned as a numeric matrix of sizeM-by-Nfor distinct block processing, or(M-m+1)-by-(N-n+1)for sliding block processing.Ahas the same data type asB.

Version History

Introduced before R2006a