zoukankan      html  css  js  c++  java
  • Retinex系列之Frankle-McCann Retinex 分类: Matlab 图像处理 2014-12-01 21:52 538人阅读 评论(2) 收藏

    一、Frankle-McCann Retinex

    Frankle-McCann算法选择一条螺旋结构的路径用于像素间的比较。如下图,算法沿着螺旋路径选取用于比较

    像素点,这种路径选择包含了整个图像的全局明暗关系。并且越靠近预测中心点选取的点数越多,因为靠的

    近的像素点与中心像素点的相关性要比远处的高。

    此迭代方案基于成对像素亮度值间的互动,这一像素对在图像中的坐标(x,y)、(xs,ys)。第一步处理的像素被

    预定义的距离D分开,下一步将比较方向顺时针旋转90度,距离D减半,直至到达单位像素距离。每一步计

    算中迭代次数nIterator由用户决定。每次迭代有四个步操作:比例(ratio)、乘积(product)、重置(reset)、平

    均(average)。

    设OP为上一步迭代的乘积;NP为当前迭代的乘积;IP为中间乘积结果;R为原始图像;符号*表示重置操作。

    实验证明几何平均效果好于算术平均,则每步迭代使用如下公式估计点处的明度值:

    放在对数域:


    变量初始化:

    OP中的所有像素值初始化为输入图像中的最大亮度值;

    初始距离设为2的指数,指数部分小于输入图像的长、宽,即:


    ;

    迭代次数nIterator一般设为4;



    二、Matlab实现

    function Test()
    ImOriginal=imread('fig5.tif');
    [m,n,z] = size(ImOriginal);
    ImOut = zeros(m,n,z);
    for i = 1:z
        ImChannel = log(double(ImOriginal(:,:,i))+eps);
        ImOut(:,:,i)=retinex_frankle_mccann(ImChannel,4); 
        ImOut(:,:,i)=exp(ImOut(:,:,i));
        a=min(min(ImOut(:,:,i)));
        b=max(max(ImOut(:,:,i)));
        ImOut(:,:,i)=((ImOut(:,:,i)-a)/(b-a))*255;     
    end
    ImOut=uint8(ImOut);
    figure(1);
    imshow(ImOriginal);
    figure(2);
    imshow(ImOut);
    imwrite(ImOut,'tt.tif');
    
    function Retinex = retinex_frankle_mccann(L, nIterations)
    global RR IP OP NP Maximum
    RR = L;
    Maximum = max(L(:));                                 % maximum color value in the image
    [nrows, ncols] = size(L);
    
    shift = 2^(fix(log2(min(nrows, ncols)))-1);          % initial shift
    OP = Maximum*ones(nrows, ncols);                     % initialize Old Product
    
    while (abs(shift) >= 1)
       for i = 1:nIterations
          CompareWith(0, shift);                         % horizontal step
          CompareWith(shift, 0);                         % vertical step
       end
       shift = -shift/2;                                 % update the shift
    end
    Retinex = NP;
    
    function CompareWith(s_row, s_col)
    global RR IP OP NP Maximum
    IP = OP;
    if (s_row + s_col > 0)
       IP((s_row+1):end, (s_col+1):end) = OP(1:(end-s_row), 1:(end-s_col)) + ...
       RR((s_row+1):end, (s_col+1):end) - RR(1:(end-s_row), 1:(end-s_col));
    else
       IP(1:(end+s_row), 1:(end+s_col)) = OP((1-s_row):end, (1-s_col):end) + ...
       RR(1:(end+s_row),1:(end+s_col)) - RR((1-s_row):end, (1-s_col):end);
    end
    IP(IP > Maximum) = Maximum;                          % The Reset operation
    NP = (IP + OP)/2;                                    % average with the previous Old Product
    OP = NP;                                             % get ready for the next comparison
    


    测试结果:

     


    注:输出时只是简单的进行线性拉伸,使得灰度值落在[0-255],没有使用更好调整方法

    参考:

    http://www.cnblogs.com/Imageshop/archive/2013/04/18/3029352.html

    http://www.cnblogs.com/sleepwalker/p/3676600.html

    http://yh-zhao0217.blog.sohu.com/169200160.html

    http://www.cs.sfu.ca/~colour/publications/IST-2000/

    [1]Land, Edwin and McCann,John, “Lightness and Retinex Theory”, Journal of the Optical Society ofAmerica, 61(1),January 1971.

    [2] Brian Funt, FlorianCiurea, and John McCann "Retinex in Matlab," Proceedings of the IS&T/SIDEighth Color Imaging Conference: Color Science, Systems and Applications, 2000.

    [3] Frankle,Jonathan and McCann, John, “Method and Apparatus for Lightness Imaging”, USPatent #4,384,336, May 17, 1983.


    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    习题2-4 求交错序列前N项和 (15分)
    015_Web WPI
    014_捆绑包与显示模式
    013_模型验证
    012_模型绑定
    011_URL和Ajax辅助器方法
    010_模板辅助器方法
    009_辅助器方法
    008_视图
    007_控制器可扩展性
  • 原文地址:https://www.cnblogs.com/luo-peng/p/4646233.html
Copyright © 2011-2022 走看看