mulscalewave.m

来自「包内提供了Contourlet和Wavelet变换进行图像增强、去噪的各种算法和」· M 代码 · 共 59 行

M
59
字号
in=imread('02.tif');
im=rgb2gray(in);
im = double(im) / 256;
figure,imshow(im);title('原始图像');axis on;
wl=3;
[co,so] = wavedec2(im,wl,'db1');
lrow = so(1,1);
lcol = so(1,2);
s1p = so(1,1)*so(1,2);
for i=2:wl+1 
    scl=wl-i+2;    % is the coefficients of scale wl-i+2
    if i==2
       s2p=so(2,1)*so(2,2);
       d=positionh(co,s2p,s1p);
       hf=s1p; %record the position of ch's first element
       ch=reshape(d,lrow,lcol);
       d=0;
       d=positionh(co,s2p,s2p+s1p);
       vf=s1p+s2p;
       cv=reshape(d,lrow,lcol);
    else
        hrow=so(i,1);
        hcol=so(i,2);
        and=account(so,wl,i);
        b=s1p+3*and;
        sclp=so(i,1)*so(i,2);
        d=positionh(co,sclp,b);
        hf=b;
        ch=reshape(d,hrow,hcol);
        d=0;
        d=positionh(co,sclp,b+sclp);
        vf=b+sclp;
        cv=reshape(d,hrow,hcol);
    end
        g=sqrt(ch.^2+cv.^2);
        mj=300; 
        c=3;
        p=0.5;
        [chr,chl]=size(ch);
        for i=1:chr
          for j=1:chl
            if abs(g(i,j))<c
               ex=(mj/c)^p;
           elseif abs(g(i,j))>=mj
               ex=1;
           else ex=(mj/abs(g(i,j)))^p;
           end
           ch(i,j)=ex*ch(i,j);
           cv(i,j)=ex*cv(i,j);
           co(hf+(j-1)*chl+i)=ch(i,j);
           co(vf+(j-1)*chl+i)=cv(i,j);
          end
        end
end
enim=waverec2(co,so,'db1'); 
figure,imshow(enim);title('增强后的图像');axis on;


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?