%D_sd2Dexam
ima1=input('image: Barbara--1;Boat--2; Finger--3; Fabric--4; Lena--5; 0--former?')
if ima1==1
   load Bloch_ba
elseif ima1==2
   load Bloch_bo
elseif ima1==3
   load Bloch_fi
   
elseif ima1==4
   load Bloch_fa
elseif ima1==5
   load Bloch_len
   
end 


seg1=input('segment:11,or 12,or 21,or 22;33--whole image;0--former; ?')
if seg1~=0
    seg=seg1;
end
if seg==33
    blo=bloch;
else
eval(['blo=bloch' int2str(seg) ';'])
end
[vb M]=size(blo);

ToX=.0001;
range_rho1=100000000000;%input('range_rho1; 111-former; ?')
if range_rho1~=111
    range_rho=[0 range_rho1];
end

 Par1 =input('spline order for sd; 0--former; ?')
 if Par1>0
 Par=Par1;
 end
 Ll1=input(' depth; ?')

st1=input('std noise; 111-former; ?')

if st1~=111
    noiss=randn(vb);
 st=st1;  
end



figure;
subplot(3,2,1)
Ll=0;
deci=2^Ll;

noi=st*noiss; 
nblo=blo+noi;

x=nblo;

ee=sum(noi(:).^2);

rho=D_defroP(Par,x,ee,Ll,range_rho,ToX);


s=D_smoothsplaP_2d(x,Par,Ll,rho) ;
ai(x);
ste=256/deci;
set(gca,'YTick',0:ste:2*ste);set(gca,'YTickLabel',{})
set(gca,'XTick',0:ste:2*ste);set(gca,'XTickLabel',{})

    [PSNR, mablod]=psnB(blo,x);
title(['\fontsize{16}STD=' num2str(st) ', PSNR=' num2str(PSNR)])
subplot(3,2,3)
[PSNR, mablod]=psnB(blo,s);

ai(s)
title(['\fontsize{16}Spl. order: '  int2str(Par) ', PSNR=' num2str(PSNR,4 ) ', \rho=' num2str(rho,2) ])
%title(['\fontsize{16}\rho=' num2str(rho)])
set(gca,'YTick',0:256:512);set(gca,'YTickLabel',{})
set(gca,'XTick',0:256:512);set(gca,'XTickLabel', {})
subplot(3,2,5)

Ll=Ll1;
deci=2^Ll;
rho=D_defroP(Par,x,ee,Ll,range_rho,ToX);
s=D_smoothsplaP_2d(x,Par,Ll,rho) ;
ai(s)
title(['\fontsize{16}Sampl=1:' int2str(deci) ',  \rho=' num2str(rho,2) ])
%title(['\fontsize{16}\rho=' num2str(rho)])
set(gca,'YTick',0:ste:2*ste);set(gca,'YTickLabel',{})
set(gca,'XTick',0:ste:2*ste);set(gca,'XTickLabel',{})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




subplot(3,2,2)
Ll=0;
deci=2^Ll;

noi=3*st*noiss; 
nblo=blo+noi;

x=nblo;

ee=sum(noi(:).^2);

rho=D_defroP(Par,x,ee,Ll,range_rho,ToX);


s=D_smoothsplaP_2d(x,Par,Ll,rho) ;
ai(x);
ste=256/deci;
set(gca,'YTick',0:ste:2*ste);set(gca,'YTickLabel',{})
set(gca,'XTick',0:ste:2*ste);set(gca,'XTickLabel',{})

    [PSNR mablod]=psnB(blo,x);
title(['\fontsize{16}STD=' num2str(3*st) ', PSNR=' num2str(PSNR)])

subplot(3,2,4)
[PSNR mablod]=psnB(blo,s);

ai(s)
title(['\fontsize{16}Spl. order: '  int2str(Par) ', PSNR=' num2str(PSNR,4 ) ', \rho=' num2str(rho,2) ])
%title(['\fontsize{16}\rho=' num2str(rho)])
set(gca,'YTick',0:256:512);set(gca,'YTickLabel',{})
set(gca,'XTick',0:256:512);set(gca,'XTickLabel', {})

subplot(3,2,6)

Ll=Ll1;
deci=2^Ll;
rho=D_defroP(Par,x,ee,Ll,range_rho,ToX);
s=D_smoothsplaP_2d(x,Par,Ll,rho) ;
ai(s)
title(['\fontsize{16}Sampl=1:' int2str(deci) ',  \rho=' num2str(rho,2) ])
%title(['\fontsize{16}\rho=' num2str(rho)])
set(gca,'YTick',0:ste:2*ste);set(gca,'YTickLabel',{})
set(gca,'XTick',0:ste:2*ste);set(gca,'XTickLabel',{})