⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quantize.m

📁 DigitalImageProcessing_base_on_Matlab 基于Matlab的数字图像处理
💻 M
字号:
%函数quantize.m:高斯概率密度函数的非均匀量化%
function [r,d]=quantize(L)                %L:重构层数         
r=linspace(0,0,L); d=linspace(0,0,L+1);
d(1)=0; d(L+1)=500;                       %设定d0=0,dL =500(代表无穷大)
d_inc=0.005; r_inc=0.003; error_bound1=0.002; error_bound2=0.003;  
r_estimate=500;tolerance=[1e-4 1e-4];                        
r_init=0.01;                              %r(1)值   
check=0;
while check==0
  r(1)=r_init;                
  for k=1:L-1
    d(k+1)=d(k);                          %猜测的d(k+1)以d(k)开始运算          
    %比对所得的r_estimate和r(k)之差,此循环在r(k)给定后找出d(k+1)% 
    while abs(r_estimate-r(k))>error_bound1       
      d(k+1)=d(k+1)+d_inc;                %验算不符合略微增加d_inc
      Int_N=quad('gau1',d(k),d(k+1),tolerance); 
      Int_D=quad('gau',d(k),d(k+1),tolerance); 
      r_estimate=Int_N/Int_D;             
    end
    r(k+1)=2*d(k+1)-r(k);                 %从d(k+1)与r(k)求r(k+1)
  end                                      
  %从公式算出的rL_estimate和r(k+1)做比较% 
  IntL_N=quad('gau1',d(L),d(L+1),tolerance);
  IntL_D=quad('gau',d(L),d(L+1),tolerance); 
  rL_estimate=IntL_N/IntL_D;
  diff=rL_estimate-r(L);
  relative_error=abs(diff)/rL_estimate;                                       
        
   if relative_error<error_bound2
    check=1;
  else
    check=0;
    r_init=r_init+r_inc;                  %不符合条件则重新选取r(1)
  end        
end  




⌨️ 快捷键说明

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