1. block_divide
% 返回的块向量构成的矩阵,其维度信息为 K^2 * N,每一列由块构成的列向量
function P = block_divide(I, K)
r = size(I, 1)/K;
c = size(I, 2)/K;
P = zeros(K^2, r*c);
f = @(A) A(:);
for i = 1:r,
for j = 1:c,
P(:, (i-1)*c+j) = f(I(K*(i-1)+1:K*i, K*(j-1)+1:K*j));
end
end
end
2. re_divide
% col: 原始图像矩阵的行数
function I = re_divide(P, col, K)
N = size(P, 2);
m = floor(sqrt(N));
b44s = [];
for i = 1:N,
b44s = [b44s, reshape(P(:, i), K, K)];
end
I = [];
for k = 1:m,
I = [I; b44s(:, (k-1)*col+1:k*col)];
end
end