Cody

# Problem 929. Rearrange coefficients after block based DCT transform.

Solution 333155

Submitted on 13 Oct 2013 by Alfonso Nieto-Castanon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% test 1 x = ones(16); for N=2.^(1:4) for M=2.^(1:4) y = block_dct2(x, N, M); y_corr = [sqrt(N*M)*ones(16/N, 16/M), zeros(16/N,16-16/M); zeros(16-16/N,16)]; assert( norm( y_corr(:) - y(:)) < 1e-10 ); end end

``` ```

2   Pass
%% test 2 x = eye(16); y_corr = eye(16); for N=2.^(1:4) y = block_dct2(x, N, N); assert( norm( y_corr(:) - y(:)) < 1e-10 ); end

``` ```

3   Pass
%% test 3 x = double(invhilb(8)>0); y = block_dct2(x, 2, 2); y_corr = [ones(4),zeros(4);zeros(4),ones(4)]; assert( norm( y_corr(:) - y(:)) < 1e-10 );

``` ```

4   Pass
%% test 4 x = double(invhilb(4)>0); y = block_dct2(x, 1, 2); y_corr = (sqrt(2)/2)*[1 1 1 1; 1 1 -1 -1; 1 1 1 1; 1 1 -1 -1]; assert( norm( y_corr(:) - y(:)) < 1e-10 );

``` ```

5   Pass
%% test 5 1x1 matrix x = 5; y = block_dct2(x, 1, 1); assert( abs(y - 5) < 1e-10 );

``` ```