retinex相关代码汇总
混合方法 SSR.m
matlab代码,本来是RGB,改成了处理灰度图像的。
%%%%%%%%%%%%%%%RGB normalisation%%%%%%%%%%%%%%%%%%%%%%
%its cascaded implementain of section of paper "A FAST SKIN REGION DETECTOR" by
%Phil Chen, Dr.Christos Greecos
%and
%section 2.1 of paper "Simple and accurate face detection in color images" by
%YUI TING PAI et al
% Coding by Madhava.S.Bhat, Dept of Electronics an communication
%Dr.Ambedkar Institute of Technology, Bangalore
%madhava.s@dr-ait.org
function[]= SSR(IMG)
IMG=rgb2gray(IMG);
figure,imshow(IMG)
title('original')
R=double(IMG);
[H,W]=size(R);
% minR=;
% minG=;
% minB=;
% [srow,scol]=find(R== & G== & B==);
% if(isempty(srow) && isempty(scol))
minR=min(min(R));
% end
R=R-minR; S=zeros(H,W);
[srow,scol]=find(R==);
[sm,sn]=size(srow); for i=:sm
S(srow(i),scol(i))=;
end
mstd=sum(sum(S))
Nstd=(H*W)-mstd; Cst=;
Cst=double(Cst);
for i=:H
for j=:W
a=R(i,j);
b=R(i,j);
Cst=a+b+Cst;
end
end
%%%%sum of black pixels%%%%%%%%%%%
blacksumR=;
for i=:sm
blacksumR=blacksumR+R(srow(i),scol(i));
end
Cstd = Cst/(*Nstd)
CavgR=sum(sum(R))./(H*W)
Rsc=Cstd./CavgR
R=R.*Rsc;
C=R;
C=C/;
Y=C;
figure,imshow(C)
title('aft 1st stage of compensation')
%normalize Y
minY=min(min(Y));
maxY=max(max(Y));
Y=255.0*(Y-minY)./(maxY-minY);
YEye=Y;
Yavg=sum(sum(Y))/(W*H) T=;
if (Yavg<)
T=1.4
elseif (Yavg>)
T=0.6
end
T
if (T~=)
RI=R.^T;
else
RI=R;
end Cfinal=uint8(RI);
figure,imshow(Cfinal)
title('Light intensity compensated')
clc;
clear all;
%%%%%%sourceImage%%%%%%%%%
sourceImage = imread('F:\Users\*****\Desktop\**图像\test.bmp');
%imshow(sourceImage); SSR(sourceImage);
效果不对,不知道哪有问题:
看灰度图的处理效果还可以。


【转载自】
图像增强算法四种,图示与源码,包括retinex(ssr、msr、msrcr)和一种混合算法 - onezeros的专栏 - CSDN博客 https://blog.csdn.net/onezeros/article/details/6342661
【其他】
SSR matlab实现单尺度retinex算法,实现图像增强。 联合开发网 - pudn.com http://www.pudn.com/Download/item/id/2776026.html
%retinex%
clc;
clear all;
%%%%%%sourceImage%%%%%%%%%
sourceImage = imread('C:\Users\huang\Desktop\����1.bmp');
imshow(sourceImage); %%%R,G,B%%%%
image_r=sourceImage(:,:,);
image_g=sourceImage(:,:,);
image_b=sourceImage(:,:,); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r=;
cParam=;
block=*r+;
sum=0.0;
for i=:block
for j=:block
gauss(i,j)=exp((-((i-r-)^+(j-r-)^))/cParam^);
sum=sum+gauss(i,j);
end
end
for i=:block
for j=:block
gauss(i,j)=gauss(i,j)/sum;
end
end %%%%%%%%%%%R%%%%%%%%%%%%%
Img = double(image_r);
K=imfilter(Img,gauss,'replicate','conv');
G=log(Img+)-log(K+); mi=min(min(G));
ma=max(max(G));
destImage_r=(G-mi)*/(ma-mi); %%%%%%%%%%%%%%G%%%%%%%%%%%%%
Img = double(image_g);
K=imfilter(Img,gauss,'replicate','conv');
G=log(Img+)-log(K+); mi=min(min(G));
ma=max(max(G));
destImage_g=(G-mi)*/(ma-mi);
%%%%%%%%%%%%%B%%%%%%%%%%%%%%%%%%
Img = double(image_b);
K=imfilter(Img,gauss,'replicate','conv');
G=log(Img+)-log(K+); mi=min(min(G));
ma=max(max(G));
destImage_b=(G-mi)*/(ma-mi);
%%%%%%%%%%%%%%%%%%
destImageSSR=cat(,destImage_r,destImage_g,destImage_b);
figure;
imshow(uint8(destImageSSR)); %etinex
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r=;
cParam1=;
cParam2=;
cParam3=;
block=*r+;
sum1=0.0;
sum2=0.0;
sum3=0.0;
for i=:block
for j=:block
gauss1(i,j)=exp((-((i-r-)^+(j-r-)^))/cParam1^);
sum1=sum1+gauss1(i,j);
gauss2(i,j)=exp((-((i-r-)^+(j-r-)^))/cParam2^);
sum2=sum2+gauss2(i,j);
gauss3(i,j)=exp((-((i-r-)^+(j-r-)^))/cParam3^);
sum3=sum3+gauss3(i,j);
end
end
for i=:block
for j=:block
gauss1(i,j)=gauss1(i,j)/sum1;
gauss2(i,j)=gauss2(i,j)/sum2;
gauss3(i,j)=gauss3(i,j)/sum3;
end
end %%%%%%%%%%%R%%%%%%%%%%%%%
Img = double(image_r);
K1=imfilter(Img,gauss1,'replicate','conv');
K2=imfilter(Img,gauss2,'replicate','conv');
K3=imfilter(Img,gauss3,'replicate','conv'); G=log(Img+)-(/)*(log(K1+)+log(K2+)+log(K3+)); mi=min(min(G));
ma=max(max(G));
destImage_r=(G-mi)*/(ma-mi); %%%%%%%%%%%%%%G%%%%%%%%%%%%%
Img = double(image_g);
K1=imfilter(Img,gauss1,'replicate','conv');
K2=imfilter(Img,gauss2,'replicate','conv');
K3=imfilter(Img,gauss3,'replicate','conv'); G=log(Img+)-(/)*(log(K1+)+log(K2+)+log(K3+)); mi=min(min(G));
ma=max(max(G));
destImage_g=(G-mi)*/(ma-mi);
%%%%%%%%%%%%%B%%%%%%%%%%%%%%%%%%
Img = double(image_b);
K1=imfilter(Img,gauss1,'replicate','conv');
K2=imfilter(Img,gauss2,'replicate','conv');
K3=imfilter(Img,gauss3,'replicate','conv'); G=log(Img+)-(/)*(log(K1+)+log(K2+)+log(K3+)); mi=min(min(G));
ma=max(max(G));
destImage_b=(G-mi)*/(ma-mi); %%%%%%%%%%%%%%%%%%
destImageMSR=cat(,destImage_r,destImage_g,destImage_b);
figure;
imshow(uint8(destImageMSR));


【别人博客里的一些效果图】
retinex图像增强算法的研究 - zmshy2128 - 博客园 https://www.cnblogs.com/zmshy2128/p/6126987.html
关于Retinex图像增强算法的一些新学习。 - Imageshop - 博客园 https://www.cnblogs.com/Imageshop/p/3810402.html
Retinex图像增强算法代码 - liyingjiang22的博客 - CSDN博客 https://blog.csdn.net/liyingjiang22/article/details/52903127
图像增强处理之:同态滤波与Retinex算法(二)McCann Retinex和McCann99 Retinex迭代算法 - 满城风絮 - CSDN博客 https://blog.csdn.net/piaoxuezhong/article/details/78248219
retinex相关代码汇总的更多相关文章
- [转帖]xserver相关知识汇总
xserver相关知识汇总 https://blog.csdn.net/QTVLC/article/details/81739984 本文主要是从以下几个方面介绍xorg-xserver 相关的知 ...
- 常见.NET功能代码汇总 (2)
常见.NET功能代码汇总 23,获取和设置分级缓存 获取缓存:首先从本地缓存获取,如果没有,再去读取分布式缓存写缓存:同时写本地缓存和分布式缓存 private static T GetGradeCa ...
- 常见.NET功能代码汇总
1,在Web上修改指定文件位置的Web.config 这里需要使用 WebConfigurationManager 类,但必须使用WebConfigurationFileMap类来指定文件位置,看代码 ...
- [ARM] Cortex-M Startup.s启动文件相关代码解释
1. 定义一个段名为CSTACK, 这里: NOROOT表示如何定义的段没有被关联,那么同意会被优化掉,如果不想被优化掉就使用ROOT. 后面的括号里数字表示如下: (1):这个段是2的1次方即2字节 ...
- Kafka Producer相关代码分析【转】
来源:https://www.zybuluo.com/jewes/note/63925 @jewes 2015-01-17 20:36 字数 1967 阅读 1093 Kafka Producer相关 ...
- 命令行方式使用abator.jar生成ibatis相关代码和sql语句xml文件
最近接手一个老项目,使用的是数据库是sql server 2008,框架是springmvc + spring + ibatis,老项目是使用abator插件生成的相关代码,现在需要增加新功能,要添加 ...
- Magento Table Rate运费国家代码汇总
Magento Table Rate是三种内置未调用第三方API运费方式中最强大的一个.通过设置国家,区域,邮编,价格来划分不同的运费等级.该方式基本能够满足轻量级的B2C商城的运费模式.这里收集下国 ...
- myBatis自动生成相关代码文件配置(Maven)
pom.xml文件添加配置 <build> <finalName>generator</finalName> <plugins> <!-- mav ...
- 临时2级页表的初始化过程 head_32.S 相关代码解释
page_pde_offset = (__PAGE_OFFSET >> 20); /* __PAGE_OFFSET是0xc0000000,page_pde_offset = 3072 = ...
随机推荐
- java jvm perf
http://www.oracle.com/technetwork/java/performance-138178.html http://www.oracle.com/technetwork/jav ...
- Top 40 Static Code Analysis Tools
https://www.softwaretestinghelp.com/tools/top-40-static-code-analysis-tools/ In this article, I have ...
- boost.asio源码剖析(三) ---- 流程分析
* 常见流程分析之一(Tcp异步连接) 我们用一个简单的demo分析Tcp异步连接的流程: #include <iostream> #include <boost/asio.hpp& ...
- 每日英语:Genetic Manipulation Extends Life of Mice 20%
By reducing the activity of one type of gene, scientists said they increased the average life span o ...
- Solr学习之四-Solr配置说明之二
上一篇的配置说明主要是说明solrconfig.xml配置中的查询部分配置,在solr的功能中另外一个重要的功能是建索引,这是提供快速查询的核心. 按照Solr学习之一所述关于搜索引擎的原理中说明了建 ...
- rpc简介、原理、实例
简介 RPC(Remote Procedure Call,远程过程调用)是建立在Socket之上的,出于一种类比的愿望,在一台机器上运行的主程序,可以调用另一台机器上准备好的子程序,就像LPC(本地过 ...
- mysql 5.7.13 安装配置方法图文教程(win10) (转)
http://www.jb51.net/article/87152.htm ***************************** MySQL是一款关系型数据库管理系统,是由Oracle旗下公司M ...
- 【Java】线程池的作用
在程序启动的时候就创建若干线程来响应处理,它们被称为线程池,里面的线程叫工作线程 第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗. 第二:提高响应速度.当任务到达时,任务 ...
- gvim配置到命令行可以使用
下载安装gvim后,把gvim的安装目录添加到环境变量.
- python基础系列教程——Python的安装与测试:python的IDE工具PyDev和pycharm,anaconda
---恢复内容开始--- python基础系列教程——Python的安装与测试:python的IDE工具PyDev和pycharm,anaconda 从头开启python的开发环境搭建.安装比较简单, ...