function R=comp_draft6(bit_F,F,enum)

%enum=16;
[K,ij]=size(F);
I=90;
J=135;

figure(1)
mF=min(F(:));
MF=max(F(:));
h=hist(F(:),mF:MF)/(K*ij);
i=find(h~=0);
-sum((h(i)).*log2(h(i)))
subplot(2,3,1)
plot(mF:MF,h)
axis tight

%bit_F=ceil(log2(max(F(:))))
mn=round(mean(F'));
C1=imf_lp(mn);
[i_c,j_c]=size(C1);
if i_c>6
   C1=[C1(1:5,:); sum(C1(6:i_c,:))];
   i_c=6;
end

for o=1:i_c
    C1(o,:)=C1(o,:)/sqrt(sum(C1(o,:).^2));
end

A=round(C1*F);

figure(2)
for o=1:i_c
    subplot(3,2,o)
    for j=1:J
        Im(:,j)=A(o,(j-1)*I+1:j*I)';
    end
    imagesc(Im)
end

bit_proj=0;
for o=1:i_c
   bit_proj=bit_proj+ceil(log2(max(A(o,:))-min(A(o,:))));
end

figure(3)
for o=1:i_c
subplot(3,2,o)
plot(C1(o,:))
axis tight
end

F1=F-round(C1'*inv(C1*C1')*A);

mF=min(F1(:));
MF=max(F1(:));
h=hist(F1(:),mF:MF)/(K*ij);
i=find(h~=0);
-sum((h(i)).*log2(h(i)))
figure(1)
subplot(2,3,2)
plot(mF:MF,h)
axis tight

Cov=F1*F1';
[V,D]=eig(Cov);
V=V(:,K+1-enum:K);
V=10^(-4)*round(10^4*V);
C=round(V'*F1);
bit_coef=0;
for ic=1:enum
   bit_coef=bit_coef+ceil(log2(max(C(ic,:))-min(C(ic,:))));
end
F1=F1-round(V*C);

figure(4)
for o=1:8
    subplot(4,2,o)
    for j=1:J
       Im(:,j)=C(enum+1-o,(j-1)*I+1:j*I)';
    end
    imagesc(Im)
end

if (enum>8 & enum<16)
   figure(5)
   for o=1:enum-8
      subplot(4,2,o)
      for j=1:J
         Im(:,j)=C(enum-8+1-o,(j-1)*I+1:j*I)';
      end
      imagesc(Im)
   end
end

mF=min(F1(:));
MF=max(F1(:));
h=hist(F1(:),mF:MF)/(K*ij);
i=find(h~=0);
-sum((h(i)).*log2(h(i)))
figure(1)
subplot(2,3,3)
plot(mF:MF,h)
axis tight

st=std(F1(:));
h=h*K*ij;
e=exp(-(mF:1:MF).^2/(2*st^2));
HL=HuffLen(e);
S=sum(HL.*h);

R=bit_F*I*J*K/(bit_F*K+14*enum*K+(2*enum+2*i_c+6)*32+I*J*(bit_coef+bit_proj)+S);