|
|
unsigned char
and there are x*y*channels elements.std::vector<unsigned char> data( x * y * channels );
|
|
data[ row*x*channels + col*channels + cha ]
|
|
abcde fghij klmno pqrst uvwxy zabcd efghi jklmn opqrs tuvwx yzabc defgh |
|
|
|
|
Idx1::operator[]
returns a reference to helper class called Idx2.Idx2::operator[]
returns a reference to the appropriate ChannelData element.
|
|
|
|
|
|
abcde fghij klmno pqrst uvwxy zabcd efghi jklmn opqrs tuvwx yzabc defgh |
program test implicit none; character, allocatable :: a(:), a3d(:,:,:) character :: NL = new_line( 'x' ) integer ni, nj, nchannels integer i, j ni = 3; nj = 4; nchannels = 5 ! Original array a = [ ( achar( iachar( 'a' ) + modulo( i - 1, 26 ) ), i = 1, ni * nj * nchannels ) ] ! Reshaped array a3d = reshape( a, [nchannels,nj,ni] ) ! allocate, copy and reshape ! Print reshaped array write( *, "( *( a ) )" ) ( ( a3d(:,j,i), NL, j = 1, nj ), NL, i = 1, ni ) deallocate( a, a3d ) end program test |
Easier in Fortran: |