資源簡介
用opencv實現retinex算法,包括單尺度和多尺度Retinex

代碼片段和文件信息
/*
*?Copyright?(c)?2006?Douglas?Gray?(dgray@soe.ucsc.edu?dr.de3ug@gmail.com)
*?All?rights?reserved.
*
*?Redistribution?and?use?in?source?and?binary?forms?with?or?without
*?modification?are?permitted?provided?that?the?following?conditions?are?met:
*?????*?Redistributions?of?source?code?must?retain?the?above?copyright
*???????notice?this?list?of?conditions?and?the?following?disclaimer.
*?????*?Redistributions?in?binary?form?must?reproduce?the?above?copyright
*???????notice?this?list?of?conditions?and?the?following?disclaimer?in?the
*???????documentation?and/or?other?materials?provided?with?the?distribution.
*?????*?Neither?the?name?of?the??nor?the
*???????names?of?its?contributors?may?be?used?to?endorse?or?promote?products
*???????derived?from?this?software?without?specific?prior?written?permission.
*
*?THIS?SOFTWARE?IS?PROVIDED?BY?Douglas?Gray?‘‘AS?IS‘‘?AND?ANY
*?EXPRESS?OR?IMPLIED?WARRANTIES?INCLUDING?BUT?NOT?LIMITED?TO?THE?IMPLIED
*?WARRANTIES?OF?MERCHANTABILITY?AND?FITNESS?FOR?A?PARTICULAR?PURPOSE?ARE
*?DISCLAIMED.?IN?NO?EVENT?SHALL??BE?LIABLE?FOR?ANY
*?DIRECT?INDIRECT?INCIDENTAL?SPECIAL?EXEMPLARY?OR?CONSEQUENTIAL?DAMAGES
*?(INCLUDING?BUT?NOT?LIMITED?TO?PROCUREMENT?OF?SUBSTITUTE?GOODS?OR?SERVICES;
*?LOSS?OF?USE?DATA?OR?PROFITS;?OR?BUSINESS?INTERRUPTION)?HOWEVER?CAUSED?AND
*?ON?ANY?THEORY?OF?LIABILITY?WHETHER?IN?CONTRACT?STRICT?LIABILITY?OR?TORT
*?(INCLUDING?NEGLIGENCE?OR?OTHERWISE)?ARISING?IN?ANY?WAY?OUT?OF?THE?USE?OF?THIS
*?SOFTWARE?EVEN?IF?ADVISED?OF?THE?POSSIBILITY?OF?SUCH?DAMAGE.
*/
#include?“retinex.h“
#include?
#include?
#include?
//#define?USE_EXACT_SIGMA
#define?pc(image?x?y?c)?image->imageData[(image->widthStep?*?y)?+?(image->nChannels?*?x)?+?c]
#define?INT_PREC?1024.0
#define?INT_PREC_BITS?10
inline?double?int2double(int?x)?{?return?(double)x?/?INT_PREC;?}
inline?int?double2int(double?x)?{?return?(int)(x?*?INT_PREC?+?0.5);?}
inline?int?int2smallint(int?x)?{?return?(x?>>?INT_PREC_BITS);?}
inline?int?int2bigint(int?x)?{?return?(x?<
//
//?CreateKernel
//
//?Summary:
//?Creates?a?normalized?1?dimensional?gaussian?kernel.
//
//?Arguments:
//?sigma?-?the?standard?deviation?of?the?gaussian?kernel.
//
//?Returns:
//?double*?-?an?array?of?values?of?length?((6*sigma)/2)?*?2?+?1.
//
//?Note:
//?Caller?is?responsable?for?deleting?the?kernel.
//
double*
CreateKernel(double?sigma)
{
int?i?x?filter_size;
double*?filter;
double?sum;
//?Reject?unreasonable?demands
if?(?sigma?>?200?)?sigma?=?200;
//?get?needed?filter?size?(enforce?oddness)
filter_size?=?(int)floor(sigma*6)?/?2;
filter_size?=?filter_size?*?2?+?1;
//?Allocate?kernel?space
filter?=?new?double[filter_size];
//?Calculate?exponential
sum?=?0;
for?(i?=?0;?i? x?=?i?-?(filter_size?/?2);
filter[i]?=?exp(?-(x*x)?/?(2*sigma*sigma)?);
sum?+=?filter[i];
}
//?Normalize
for?(i?=?0?x;?i? filter[i]?/=?sum;
return?filter;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2257??2015-05-22?17:15??retinex.h
?????文件???????14325??2015-05-30?14:33??retinex.cpp
- 上一篇:c++21天課程.txt
- 下一篇:PSO-LS-SVM代碼
評論
共有 條評論