91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

opencv實現圖像顏色增強算法,vs2013+opencv2.4.13 實現。、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

資源截圖

代碼片段和文件信息

#include
#include
using?namespace?std;
using?namespace?cv;

/*
Stretch?color?saturation?to?cover?maximum?possible?range“
“This?simple?plug-in?does?an?automatic?saturation?stretch.
For?each?channel?in?the?image?it?finds?the?minimum?and?maximum?values...
it?uses?those?values?to?stretch?the?individual?histograms?to?the?full?range.
For?some?images?it?may?do?just?what?you?want;?for?others?it?may?not?work?that?well.
This?version?differs?from?Contrast?Autostretch?in?that?it?works?in?HSV?space?and?preserves?hue.

*/

double?vdelta?=?200;
double?stheta?=?30;

void?find_vhi_vlo(const?Mat?&img?double?&vhi?double?&vlo)
{
int?width?=?img.cols;
int?height?=?img.rows;

uchar?min;

vector?BGR;
split(img?BGR);
//conver?to?CMY
BGR[0]?=?255?-?BGR[0];
BGR[1]?=?255?-?BGR[1];
BGR[2]?=?255?-?BGR[2];

Mat?CMY(img.size()?CV_8UC3);
merge(BGR?CMY);


for?(int?i?=?0;?i? {
Vec3b?*pImg?=?CMY.ptr(i);
for?(int?j?=?0;?j? {
min?=?pImg[j][0];
if?(pImg[j][1]? if?(pImg[j][2]? for?(int?k?=?0;?k? {
pImg[j][k]?-=?min;


}
}
}

Mat?HSV?=?Mat(CMY.size()?CV_8UC3);
//imshow(“cmy“CMY);
cvtColor(CMY?HSV?COLOR_BGR2HSV);


vector?vHSV;

split(HSV?vHSV);

//
////find?Vmin?and?Vmax

double?vMin?=?1.0;
double?vMax?=?.0;

for?(int?i?=?0;?i? {
uchar?*pImg?=?vHSV[2].ptr(i);
for?(int?j?=?0;?j? {
double?v?=?(double)pImg[j]?/?255.0;

if?(v?>?vMax) vMax?=?v;
if?(v? }
}

vhi?=?vMax;
vlo?=?vMin;

}
//v線性量化
//img單通道
void?quantizing_v(Mat?&img?double?vMax?double?vMin)
{
if?(vMax?==?vMin) return;
if?(img.channels()?!=?1) return;

int?width?=?img.cols;
int?height?=?img.rows;

double?delta?=?300.0;
for?(int?i?=?0;?i? {
uchar?*pImg?=?img.ptr(i);
for?(int?j?=?0;?j? {
//double?oldPixel?=?(double)pImg[j];
double?newPixel?=?((double)pImg[j]?/?255?-?vMin)?/?(vMax?-?vMin);
int?tmp?=?int(newPixel?*?delta);
if?(tmp?>255)
pImg[j]?=?255;
else?if?(tmp? pImg[j]?=?0;
else
pImg[j]?=?(uchar)tmp;

}
}
//cout?<}



void?color_enhance(const?Mat?&img?Mat?&dst?double?vMax?double?vMin)
{
double?v;//v量化

int?width?=?img.cols;
int?height?=?img.rows;

uchar?min;
vector?BGR;
split(img?BGR);
//equalizeHist(BGR[2]BGR[2]);

//conver?to?CMY
BGR[0]?=?255?-?BGR[0];
BGR[1]?=?255?-?BGR[1];
BGR[2]?=?255?-?BGR[2];

Mat?CMY(img.size()?CV_8UC3);
merge(BGR?CMY);

//imshow(“cmy1“?CMY);

Mat?minMat(img.size()?CV_8UC1);

for?(int?i?=?0;?i? {
Vec3b?*pImg?=?CMY.ptr(i);
uchar?*pMin?=?minMat.ptr(i);

for?(int?j?=?0;?j? {
min?=?pImg[j][0];

評論

共有 條評論