Retinex实例

article/2025/11/6 21:22:08

Retinex实例

1、代码:

#include <iostream>
#include <cstring>
#include "opencv2/opencv.hpp"
using namespace cv;
static void help(std::string errorMessage)
{
	std::cout<<"Program init error : "<<errorMessage<<std::endl;
	std::cout<<"\nProgram call procedure : retinaDemo [processing mode] [Optional : media target] [Optional LAST parameter: \"log\" to activate retina log sampling]"<<std::endl;
	std::cout<<"\t[processing mode] :"<<std::endl;
	std::cout<<"\t -image : for still image processing"<<std::endl;
	std::cout<<"\t -video : for video stream processing"<<std::endl;
	std::cout<<"\t[Optional : media target] :"<<std::endl;
	std::cout<<"\t if processing an image or video file, then, specify the path and filename of the target to process"<<std::endl;
	std::cout<<"\t leave empty if processing video stream coming from a connected video device"<<std::endl;
	std::cout<<"\t[Optional : activate retina log sampling] : an optional last parameter can be specified for retina spatial log sampling"<<std::endl;
	std::cout<<"\t set \"log\" without quotes to activate this sampling, output frame size will be divided by 4"<<std::endl;
	std::cout<<"\nExamples:"<<std::endl;
	std::cout<<"\t-Image processing : ./retinaDemo -image lena.jpg"<<std::endl;
	std::cout<<"\t-Image processing with log sampling : ./retinaDemo -image lena.jpg log"<<std::endl;
	std::cout<<"\t-Video processing : ./retinaDemo -video myMovie.mp4"<<std::endl;
	std::cout<<"\t-Live video processing : ./retinaDemo -video"<<std::endl;
	std::cout<<"\nPlease start again with new parameters"<<std::endl;
	std::cout<<"****************************************************"<<std::endl;
	std::cout<<" NOTE : this program generates the default retina parameters file 'RetinaDefaultParameters.xml'"<<std::endl;
	std::cout<<" => you can use this to fine tune parameters and load them if you save to file 'RetinaSpecificParameters.xml'"<<std::endl;
}
int main(int argc, char* argv[]) 
{
	bool useLogSampling = false; // "log" // check if user wants retina log sampling processing
	std::string inputMediaType="-image"; // argv[1],如果为“-video”且useLogSampling = false则从摄像头读取视频
	string imageOrVideoName = "noise image.jpg"; // argv[2]--lena.jpg
	// declare the retina input buffer... that will be fed differently in regard of the input media
	Mat inputFrame, image;
	VideoCapture videoCapture; // in case a video media is used, its manager is declared here
	if (!strcmp(inputMediaType.c_str(), "-image") )		//处理图像
	{
		std::cout<<"RetinaDemo: processing image "<<imageOrVideoName<<std::endl;
		inputFrame = imread(imageOrVideoName, 0); // load image in RGB mode
	}
	else	//处理视频
	{
		if (!strcmp(inputMediaType.c_str(), "-video"))
		{
			if (useLogSampling) // attempt to grab images from a video capture device
			{
				videoCapture.open(0);
			}
			else// attempt to grab images from a video filestream
			{
				std::cout<<"RetinaDemo: processing video stream "<<imageOrVideoName<<std::endl;
				videoCapture.open(imageOrVideoName);
			}
			// grab a first frame to check if everything is ok
			videoCapture>>inputFrame;
		}
		else
		{
			help("bad command parameter");
			return -1;
		}
	}
	if (inputFrame.empty())	
	{
		help("Input media could not be loaded, aborting");
		return -1;
	}
	try
	{
		// create a retina instance with default parameters setup, uncomment the initialisation you wanna test
		Ptr<Retina> myRetina;
		// if the last parameter is 'log', then activate log sampling (favour foveal vision and subsamples peripheral vision)
		if (useLogSampling)
		{
			myRetina = new cv::Retina(inputFrame.size(), true, cv::RETINA_COLOR_BAYER, true, 2.0, 10.0);
		}
		else// -> else allocate "classical" retina :
			myRetina = new cv::Retina(inputFrame.size());
		//               myRetina = &inputFrame.clone();
		// save default retina parameters file in order to let you see this and maybe modify it and reload using method "setup"
		myRetina->write("RetinaDefaultParameters.xml");
		// load parameters if file exists
		//        myRetina->setup("RetinaSpecificParameters.xml");
		myRetina->setup("RetinaDefaultParameters.xml");
		//        // reset all retina buffers (imagine you close your eyes for a long time)
		myRetina->clearBuffers();
		// declare retina output buffers
		cv::Mat retinaOutput_parvo;
		cv::Mat retinaOutput_magno;
		// processing loop with no stop condition
		for(;;)
		{
			// if using video stream, then, grabbing a new frame, else, input remains the same
			if (videoCapture.isOpened())
				videoCapture>>inputFrame;
			// run retina filter on the loaded input frame
			myRetina->run(inputFrame);

			// Retrieve and display retina output
			myRetina->getParvo(retinaOutput_parvo);
			myRetina->getMagno(retinaOutput_magno);
			cv::imshow("retina input", inputFrame);
			cv::imshow("Retina Parvo", retinaOutput_parvo);
			cv::imshow("Retina Magno", retinaOutput_magno);
			cv::waitKey(10);
		}
	}
	catch(cv::Exception e)
	{
		std::cerr<<"Error using Retina : "<<e.what()<<std::endl;
	}
	// Program end message
	std::cout<<"Retina demo end"<<std::endl;
	return 0;
}

2、运行结果



http://chatgpt.dhexx.cn/article/EFSuwvTt.shtml

相关文章

matlab Retinex图像增强算法

Retinex理论在彩色图像增强、图像去雾、彩色图像恢复方面拥有很好的效果&#xff0c;下面介绍一下我对该算法的理解。 Retinex理论 Retinex理论始于Land和McCann于20世纪60年代作出的一系列贡献,其基本思想是人感知到某点的颜色和亮度并不仅仅取决于该点进入人眼的绝对光线&a…

深入探究Retinex

深入探究Retinex 导读Retinex动态范围增强Retinex核心理论 带色彩恢复的Retinex->MSRCR 导读 Retinex理论是建立在人对颜色感知的恒常性上&#xff0c;真实物体都是无色的&#xff0c;所有颜色的产生都是光和物体相互作用&#xff0c;再被人眼感知的过程。在这样的理论基础下…

Retinex图像增强算法——SSR,MSR,MSRCR,MSRCP,autoMSRCR

系列文章目录 关于OpenCV的一些图像处理函数 图象基本操作&#xff08;读取、显示、通道提取、边界填充、融合、保存&#xff09; Retinex图像增强算法——SSR,MSR,MSRCR,MSRCP,autoMSRCR 文章目录 系列文章目录前言一、Retinex理论二、算法目的&#xff1a;三、Retinex基础算…

Retinex图像增强算法

Retinex图像增强算法 Retinex是一种常用的建立在科学实验和科学分析基础上的图像增强方法&#xff0c;它是Edwin.H.Land于1963年提出的。就跟Matlab是由Matrix和Laboratory合成的一样&#xff0c;Retinex也是由两个单词合成的一个词语&#xff0c;他们分别是retina 和cortex&am…

图像增强算法Python实现之Retinex(含代码)

Retinex是一种常用的建立在科学实验和科学分析基础上的图像增强方法&#xff0c;它是Edwin.H.Land于1963年提出的。就跟Matlab是由Matrix和Laboratory合成的一样&#xff0c;Retinex也是由两个单词合成的一个词语&#xff0c;他们分别是retina 和cortex&#xff0c;即&#xff…

Retinex图像增强

Retinex是一种常用的建立在科学实验和科学分析基础上的图像增强方法。就跟Matlab是由Matrix和Laboratory合成的一样&#xff0c;Retinex也是由两个单词合成的一个词语&#xff0c;他们分别是retina 和cortex&#xff0c;即&#xff1a;视网膜和皮层。Land的retinex模式是建立在…

图像处理:Retinex算法

目录 前言 概念介绍 Retinex算法理论 单尺度Retinex&#xff08;SSR&#xff09; 多尺度Retinex&#xff08;MSR&#xff09; 多尺度自适应增益Retinex&#xff08;MSRCR&#xff09; Opencv实现Retinex算法 SSR算法 MCR算法 MSRCR算法 效果展示 总结 参考文章 前…

Retinex

Retinex图像增强算法 前一段时间研究了一下图像增强算法&#xff0c;发现Retinex理论在彩色图像增强、图像去雾、彩色图像恢复方面拥有很好的效果&#xff0c;下面介绍一下我对该算法的理解。 Retinex理论 Retinex理论始于Land和McCann于20世纪60年代作出的一系列贡献,其基本思…

Retinex算法详解

Retinex是一种常用的建立在科学实验和科学分析基础上的图像增强方法&#xff0c;它是Edwin.H.Land于1963年提出的。就跟Matlab是由Matrix和Laboratory合成的一样&#xff0c;Retinex也是由两个单词合成的一个词语&#xff0c;他们分别是retina 和cortex&#xff0c;即&#xff…

关于Retinex理论的一些理解

目前一直在参与关于Retinex的相关课题&#xff0c;并完成了许多模型的构建&#xff0c;本文以个人的见解介绍Retinex的相关理论 1. 基本原理 Retinex理论是上世纪八十年代由land等人提出的算法。该理论认为人眼可以感知近似一致的色彩信息&#xff0c;这种性质称为色彩…

Retinex理解

Retinex是一种常用的建立在科学实验和科学分析基础上的图像增强方法,它是Edwin.H.Land于1963年提出的。就跟Matlab是由Matrix和Laboratory合成的一样,Retinex也是由两个单词合成的一个词语,他们分别是retina 和cortex,即:视网膜和皮层。Land的retinex模式是建立在以下三个…

Retinex理论,单尺度Retinex、多尺度Retinex(MSR)、带颜色恢复的多尺度 Retinex(MSRCR)原理

1、Retinex理论 Retinex 是两个单词合成的&#xff0c;它们分别是 retina &#xff08;视网膜&#xff09;和 cortex &#xff08;皮层&#xff09;&#xff0c;因此 Retinex 理论很多时候也被称为是视网膜皮层理论。 最初的基于 Retinex 理论的模型提出了一个人眼视觉系统 (…

图像增强算法Retinex原理与实现详解

文章目录 1. 引言2. Retinex算法原理2.1 单尺度Retinex示例代码 2.2 多尺度Retinex示例代码 2.3 颜色恢复示例代码 2.4 最终图像处理代码示例 3. Retinex算法的Python实现4. 完结 1. 引言 图像增强是图像处理中的重要技术之一&#xff0c;它可以改善图像的亮度、对比度和颜色等…

(学习笔记)图像处理——Retinex增强

文章目录 前言原理发展单尺度算法&#xff08;SSR&#xff09;多尺度算法&#xff08;MSR&#xff09;带有色彩恢复的多尺度 实现 前言 Retinex算法由Land于1986年在《An alternative technique for the computation of the designator in the retinex theory of color vision…

Retinex 算法

目录 1、Retinex 理论及数学模型 2、Retinex 算法发展历程 2.1 基于迭代的 Retinex 算法 2.1.1 Frankle-McCann Retinex 算法 2.1.2 McCann99 Retinex 算法 2.2 基于中心环绕的 Retinex 算法 2.2.1 SSR算法&#xff08;单尺度&#xff09; 2.2.2 MSR算法&#xff08;多…

分享一个免费巨好用的shell工具

finalshell 是国产的shell工具&#xff0c;免费&#xff0c;不过可以购买vip&#xff0c;vip功能就是机器进程管理&#xff0c;基本用不上&#xff0c;所以我们只用免费版 功能包含&#xff0c;服务器连接&#xff0c;服务器管理&#xff0c;上传文件&#xff0c;文件可视化操…

shell之常用小工具(sort、uniq、tr、cut)

目录 一、sort 排序 1、格式 2、常用选项 3、sort 例子 1、不加任何选项 如&#xff1a;sort /etc/passwd 2、 去重 &#xff08;sort -u&#xff09; 3、 指定分隔符&#xff08;-t&#xff09;&#xff0c;指定排序的列&#xff08;-k&#xff09;&#xff0c;升序排列…

shell之常用工具的使用

shell入门 文章目录 shell入门一、文本处理工具1. grep工具2. cut工具3. sort工具4.uniq工具5.tee工具6.diff工具7. paste工具8. tr工具二、bash的特性1 、常用的通配符2、bash中的引号&#xff08;重点&#xff09; 一、文本处理工具 1. grep工具 grep是行过滤工具&#xff…

shell工具finalShell

qitashell工具的不足 对于运维人员来说&#xff0c; 使用的最常用的远程终端连接工具无非就是crt或者Xshell, 而crt则需要破解才能使用&#xff0c; Xshell虽说可以免费使用&#xff0c; 但经常在启动的时候会要求你购买&#xff0c; 然后一直卡住不让你启动&#xff0c; 既耽…

shell学习☞shell工具

一、shell工具 1、cut[选项参数] filename&#xff1a;从文件的每一行剪切字解、字符和字段并将这些字节、字符和字段输 选项参数&#xff1a; -f&#xff1a;列号&#xff0c;提取第几列 -d&#xff1a;分隔符&#xff08;默认是制表符&#xff09;&#xff0c;按照指定的分…