matlab Retinex图像增强算法
Retinex理论在彩色图像增强、图像去雾、彩色图像恢复方面拥有很好的效果,下面介绍一下我对该算法的理解。
Retinex理论
Retinex理论始于Land和McCann于20世纪60年代作出的一系列贡献,其基本思想是人感知到某点的颜色和亮度并不仅仅取决于该点进入人眼的绝对光线,还和其周围的颜色和亮度有关。Retinex这个词是由视网膜(Retina)和大脑皮层(Cortex)两个词组合构成的.Land之所以设计这个词,是为了表明他不清楚视觉系统的特性究竟取决于此两个生理结构中的哪一个,抑或是与两者都有关系。
Land的Retinex模型是建立在以下的基础之上的:
一、真实世界是无颜色的,我们所感知的颜色是光与物质的相互作用的结果。我们见到的水是无色的,但是水膜—肥皂膜却是显现五彩缤纷,那是薄膜表面光干涉的结果;
二、每一颜色区域由给定波长的红、绿、蓝三原色构成的;
三、三原色决定了每个单位区域的颜色。
Retinex 理论的基本内容是物体的颜色是由物体对长波(红)、中波(绿)和短波(蓝)光线的反射能力决定的,而不是由反射光强度的绝对值决定的;物体的色彩不受光照非均性的影响,具有一致性,即Retinex理论是以色感一致性(颜色恒常性)为基础的。如下图所示,观察者所看到的物体的图像S是由物体表面对入射光L反射得到的,反射率R由物体本身决定,不受入射光L变化。
图1.Retinex理论中图像的构成
Retinex理论的基本假设是原始图像S是光照图像L和反射率图像R的乘积,即可表示为下式的形式:
基于Retinex的图像增强的目的就是从原始图像S中估计出光照L,从而分解出R,消除光照不均的影响,以改善图像的视觉效果,正如人类视觉系统那样。在处理中,通常将图像转至对数域,即,从而将乘积关系转换为和的关系:
Retinex方法的核心就是估测照度L,从图像S中估测L分量,并去除L分量,得到原始反射分量R,即:
函数实现对照度L的估计(可以去这么理解,实际很多都是直接估计r分量)。
Retinex理论的理解
如果大家看论文,那么在接下去的篇幅当中,肯定会介绍两个经典的Retinex算法:基于路径的Retinex以及基于中心/环绕Retinex。在介绍两个经典的Retinex算法之前,我先来讲一点个人的理解,以便第一次接触该理论的朋友能够更快速地理解。当然,如果我的理解有问题,也请大家帮忙指出。
在极端情况下,我们大可以认为整幅图像中的分量都是均匀的,那么最简单的估计照度L的方式就是在将图像变换到对数域后对整幅图像求均值。因此,我设计了以下算法来验证自己的猜想,流程如下:
这里为了简化描述,省略了对图像本身格式的变换,算法用Matlab实现:
% ImOriginal:原始图像
% type:'add'表示分量是加性的,如雾天图像;'mult'表示分量是乘性的,如对照度的估计
[m,n,z] = size(ImOriginal);
ImOut = uint8(zeros(m,n,z));
for i = 1:zif strcmp(type,'add')ImChannel = double(ImOriginal(:,:,i))+eps;elseif strcmp(type,'mult')ImChannel = log(double(ImOriginal(:,:,i))+eps);elseerror('type must be ''add'' or ''mult''');endImOut(:,:,i) = EnhanceOneChannel(ImChannel);
end
ImOut = max(min(ImOut,255), 0);
end
function ImOut = EnhanceOneChannel(ImChannel)
% 计算计算单个通道的反射分量
% 1.对全图进行照射分量估计
% 2.减去照射分量
% 3.灰度拉伸
ImChannel = ImChannel./max(ImChannel(:));
ImRetinex = round(exp(ImChannel.*5.54));
ImOut = uint8(ImRetinex);
end
为了验证算法的有效性,这里使用经典的Retinex算法与我所用的算法进行对比试验,效果如下:
http://www.cs.sfu.ca/~colour/publications/IST-2000/
McCann Retinex算法
1. 将原图像变换到对数域,彩色图像对各通道都进行对数变换;
3. 计算路径,如上图8所示,这里令为路径上的点,从远到近排列;
公式所表示的大致意思为:从远到近,中心点像素值减去路径上的像素值得到的差值的一半与前一时刻的估计值之间的和。最终,中心像素点的像素大致的形式为
图9.算法的测试图(来自Retinex in Matlab)
function Retinex = retinex_frankle_mccann(L, nIterations)% RETINEX_FRANKLE_McCANN:
% Computes the raw Retinex output from an intensity image, based on the
% original model described in:
% Frankle, J. and McCann, J., "Method and Apparatus for Lightness Imaging"
% US Patent #4,384,336, May 17, 1983
%
% INPUT: L - logarithmic single-channel intensity image to be processed
% nIterations - number of Retinex iterations
%
% OUTPUT: Retinex - raw Retinex output
%
% NOTES: - The input image is assumed to be logarithmic and in the range [0..1]
% - To obtain the retinex "sensation" prediction, a look-up-table needs to
% be applied to the raw retinex output
% - For colour images, apply the algorithm individually for each channel
%
% AUTHORS: Florian Ciurea, Brian Funt and John McCann.
% Code developed at Simon Fraser University.
%
% For information about the code see: Brian Funt, Florian Ciurea, and John McCann
% "Retinex in Matlab," by Proceedings of the IS&T/SID Eighth Color Imaging
% Conference: Color Science, Systems and Applications, 2000, pp 112-121.
%
% paper available online at http://www.cs.sfu.ca/~colour/publications/IST-2000/
%
% Copyright 2000. Permission granted to use and copy the code for research and
% educational purposes only. Sale of the code is not permitted. The code may be
% redistributed so long as the original source and authors are cited.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 Productwhile (abs(shift) >= 1)for i = 1:nIterationsCompareWith(0, shift); % horizontal stepCompareWith(shift, 0); % vertical stependshift = -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));
elseIP(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
McCann99 Retinex算法
图像金字塔的概念很简单,就是对图像进行下采样,以多分辨率的形式表示图像。最顶层的图像分辨率最低,底层的最高(一般为原图)。
1. 将原图像变换到对数域,彩色图像对各通道都进行对数变换;
2. 初始化(计算图像金字塔层数;初始化常数图像矩阵,该矩阵作为进行迭代运算的初始值);
3. 从顶层开始,到最后一层进行8邻域比较运算,运算规则与MccCann Retinex算法相同,见上一节步骤4;
4. 第n层运算结束后对第n层的运算结果进行插值,变成原来的两倍,与n+1层大小相同(此处默认n越大越靠近底层);
function Retinex = retinex_mccann99(L, nIterations)global OPE RRE Maximum
[nrows ncols] = size(L); % get size of the input image
; % compute the number of pyramid layers
2; % size of image to process for layer 0
2;
25not25error('invalid image size.') % at first layer
end
Maximum = max(L(:)); % maximum color value in the image
; % initialize Old Product
0:nLayersRR = ImageDownResolution(L, 2; % reduce input to required layer sizeOPE = [zeros(nrows,11; % pad OP with additional columns
12; OPE; zeros(1,ncols+2)]; % and rows
1; % pad RR with additional columns
1; RRE; RRE(end,:)]; % and rowsfor iter = 1:nIterationsCompareWithNeighbor(-10; % North
11; % North-East
01; % East
11; % South-East
10; % South
11; % South-West
01; % West
11; % North-WestendNP = OPE(2121;
105; %%% these two lines are equivalent with
105; %%% OP = imresize(NP, 2) if using Image
2; ncols = 2*ncols; % Processing Toolbox in MATLAB
end
Retinex = NP;function CompareWithNeighbor(dif_row, dif_col)
global OPE RRE Maximum% Ratio-Product operation
IP = OPE(2dif_row:12dif_col:1+dif_col)) + ...RRE(21212dif_row:12dif_col:1;IP(IP > Maximum) = Maximum; % The Reset step% ignore the results obtained inor columns for which the neighbors are undefined
if (dif_col == -11212; end
1211; end
11221; end
1121; end
21212; % The Averaging operation
2121;function Layers = ComputeLayers(nrows, ncols)
power = 2; % start from the Greatest Common Divisor
100)))power = power/2; % and find the greatest common divisor
2
Layers = log2(power);function Result = ImageDownResolution(A, blocksize)
[rows, cols] = size(A); % the input matrix A is viewed as
; % a series of square blocks
; % of size = blocksize
;
1:result_rows % then each pixel is computed asfor crt_col = 1:result_cols % the average of each such blockResult(crt_row, crt_col) = mean2(A(11blocksize:crt_row*blocksize, ...11blocksize:;end
en
总结
matlab Retinex图像增强算法相关推荐
- 关于Retinex图像增强算法的一些新学习
关于Retinex图像增强算法的一些新学习. - Imageshop 时间 2014-06-26 16:50:00 博客园精华区 原文 http://www.cnblogs.com/Imagesh ...
- Retinex图像增强算法——SSR,MSR,MSRCR,MSRCP,autoMSRCR
系列文章目录 关于OpenCV的一些图像处理函数 图象基本操作(读取.显示.通道提取.边界填充.融合.保存) Retinex图像增强算法--SSR,MSR,MSRCR,MSRCP,autoMSRCR ...
- 图像去雾(二)Retinex图像增强算法
前一段时间研究了一下图像增强算法,发现Retinex理论在彩色图像增强.图像去雾.彩色图像恢复方面拥有很好的效果,下面介绍一下我对该算法的理解. Retinex理论 Retinex理论始于Land和M ...
- Retinex图像增强算法(针对彩色图像)
前一段时间研究了一下图像增强算法,发现Retinex理论在彩色图像增强.图像去雾.彩色图像恢复方面拥有很好的效果,下面介绍一下我对该算法的理解. Retinex理论 Retinex理论始于Land和M ...
- 关于Retinex图像增强算法的一些新学习。
最近再次看了一下IPOL网站,有一篇最近发表的文章,名字就是Multiscale Retinex,感觉自己对这个已经基本了解了,但还是进去看了看,也有一些收获,于是抽空把他们稍微整理了下,原始文章及其 ...
- matlab血管图像增强算法,基于Hessian特征的视网膜血管图像的增强滤波算法
第30卷第3期 2013年6月 Vol.30 No.3 Jun.,2013 华 东 交 通 大 学 学 报 Journal of East China Jiaotong University 文章编号 ...
- COI实验室技能:常见的图像增强算法(含MATLAB代码)
COI实验室技能:常见的图像增强算法(含MATLAB代码) 成像系统采集到的图片有时不一定具有很好的图像质量,往往需要进行一些图像增强的操作.本文主要整理了几种常见的图像增强算法,包括:同态滤波. ...
- 荔枝hsv空间图像分割程序matlab,基于Retinex图像增强的不同光照条件下的成熟荔枝识别_熊俊涛...
第29卷第12期农业工程学报V ol.29 No.12 170 2013年6月Transactions of the Chinese Society of Agricultural Engineeri ...
- matlab ahe,基于直方图的图像增强算法(HE、CLAHE、Retinex)之(二)
作为图像增强算法系列的第二篇文章,下面我们将要介绍功能强大.用途广泛.影响深远的对比度有限的自适应直方图均衡(CLAHE,Contrast Limited Adaptive Histogram Equ ...
最新文章
- 【Python】关于jupyter几个不得不知道的tips
- 皇室战争:暗夜女巫重做,去掉亡语机制后,她凉的可能会更快
- Spring IOC-BeanFactory的继承体系结构
- 简易的实现对象内存池
- OpenMMLab 生成模型算法库发布,打工人也能玩转图像生成!
- Confluence 6 管理协同编辑 - 最大编辑者的限制
- 多个项目共用同一个redis_分区:如何在多个Redis实例之间拆分数据
- hibernate 如何安装_python如何搭建WEB服务?
- noip模拟赛 SAC E#1 - 一道中档题 Factorial
- 高质量C编程00-汇总
- html左侧浮动广告代码,Html+CSS浮动的广告条实现分解
- 通俗易懂物联网(11):物联网解决方案设计
- 《云云众声》第94期:HP网络策略遭质疑 IBM牵手ARM发力物联网
- 最好的远程桌面破解软件frdpb_v2
- KuPlay:社区运营会是下一个风口吗?
- javascript bool 强制类型转换
- 论坛常用语的英文说法
- Chrome之连接到网络 您正在使用的网络可能会要求您访问其登录页面解决方案
- 文件管理工具,教你批量删除文件夹原名称并添加编号
- 树莓派python3.7.3安装opencv、TensorFlow2.3
热门文章
- 数据分析第一步--数据采集怎么进行埋点?
- 贝叶斯学习--极大后验假设学习
- 【机器学习算法-python实现】决策树-Decision tree(1) 信息熵划分数据集
- Python零碎知识(6):split 和 join
- 分布式计算Hadoop系列之如何修改Eclipse插件
- mongodb 从一台服务器拷贝到另一台服务器_拥有一台HECS云服务器,是怎样一种体验...
- 逻辑回归实例--乳腺癌肿瘤预测
- 数据分析利器--Pandas
- 【极客blog图文讲解】ruby以及Jekyll的环境配置(针对mac linux)
- 从mysql高可用架构看高可用架构设计