问题
I am working on Image compression based on orthogonal polynomial transformation. My input image is gray scale image of size 256*256. i divide this image into 4 by 4 blocks. and than apply the orthogonal polynomial operator on each block. but I am not getting correct coefficient. Example:
If I have a block 4x4
of Input image:
I=[5 11 8 10;9 8 4 12; 1 10 11 4;19 6 15 7];
and my polynomial operator for n=4
is:
[M] = [p0 p1 p2 p3]=[1 -3 1 -3;1 -1 -1 9;1 1 -1 -9;1 3 1 3]
After finding the outer product:
[20 -24 24 -16; -24 84 -80 24;24 -80 84 -24;-16 24 -24 20]
when I applied this on input image blocks, my answer is:
[-396 172 88 -104; 1012 -248 -376 616 -972 320 436 -552; 492 -104 4 172]
which is wrong. It should be
[140 0 -6 -10; 32 -112 2 -174; 22 -30 8 -40;34 -54 84 -8]
what I have done wrong?
My MATLAB code to find orthogonal polynomial operator is given below.
clc
clear all
close all
ID=imread('cameraman.tif'); % input image
I=double(ID);
imshow(ID);
[r,c]=size(I);
y1=zeros(r,c);
x=1:4;
n=4;
mu=(n+1)/2;
p0=[1 1 1 1];
p1=x-mu;
p2=(x-mu).^2-(n.^2-1)/12;
p3=(x-mu).^3-((x-mu)*(3*n.^2-7))/20;
P=[p0;p1; p2; p3];
N=[1 1 1 1;-1.5 -0.5 0.5 1.5;1 -1 -1 1;-0.3 0.9 -0.9 0.3];
M=[1 1 1 1;-3 -1 1 3;1 -1 -1 1;-3 9 -9 3]; % after sacling
v=M';
O=M.*v;
T=O'; % Orthogonal polynomial operator
for i=1:4:r
for j=1:4:c
y1(i:i+3,j:j+3)=I(i:i+3,j:j+3).*(double(T));
end
end
figure,imshow(uint8(y1))
y1
来源:https://stackoverflow.com/questions/44163962/how-to-apply-orthogonal-polynomial-transformation-on-an-image-for-image-compress