导读:
八月 23rd, 2007 by admin
谁有啊,因为我对vc不是很熟悉,所以自己不会做
网友回答:
发表者:sunrise
去intel的网站看看,上面有图像处理的库。
发表者:serenade
//调整图像的色度、亮度、饱和度
//作者:吴梦华 csdn上叫神曲
//
[email protected]
//2003-3-1
//用法:使用changehls函数,图像不能够带pitch。
//作用和photoshop的hue/saturation操作一致,取值范围也一样。
//要求图像为565
//目前为止只测试过改变色度,其它若有问题可以和我联系。
void changehls( word *pwimagebuf, int width, int height, int hue,
int lig, int sat )
{
float liglow=0;
float lighigh=1;
if( lig<0 )
lighigh = 1+lig/100.0f;
else if( lig>0 )
liglow = lig/100.0f;
float satlow=0;
float sathigh=1;
if( sat<0 )
sathigh = 1+sat/100.0f;
else if( sat>0 )
satlow = sat/100.0f;
int index=0;
float hls[3];
word color = 0xffff;
rgbtohls( hls, &color);
for( int row=0; row for( int col=0; col {
rgbtohls( hls, &pwimagebuf[index] );
// change hls
if( hls[0] != -1 )
{
hls[0] += hue;
hls[0] = (float)( (int)hls[0] % 360 );
if( hls[0]<0 ) hls[0]+=360;
if( hls[0]>360 ) hls[0]-=360;
hls[1] = (lighigh-liglow)*hls[1]+liglow;
hls[2] = (sathigh-satlow)*hls[2]+satlow;
}
else
hls[1] = (lighigh-liglow)*hls[1]+liglow;
pwimagebuf[index] = hlstorgb( hls );
index++;
}
}
void rgbtohls( float *phls, word *prgb )
{
float r,g,b;
r = ((*prgb)>>11)/31.0f;
g = (((*prgb)&0x7e0)>>5)/63.0f;
b = ((*prgb)&0x1f) / 31.0f;
// determine the lighteness.
float m1;
m1 = max( r,g );
m1 = max( m1, b );
float m2;
m2 = min( r,g );
m2 = min( m2, b );
float l = (m1+m2)/2;
// determine the sat
float s=0,h=0;
if( m1 == m2 )
{
s=0;
h=-1; // undefined.
}
else
{
if( l<= 0.5f )
s = (m1-m2)/(m1+m2);
else
s = (m1-m2)/(2-m1-m2);
//determine the hue
float cr = (m1-r)/(m1-m2);
float cg = (m1-g)/(m1-m2);
float cb = (m1-b)/(m1-m2);
if( r==m1) h = cb-cg;
if( g==m1) h = 2+cr-cb;
if( b==m1) h = 4+cg-cr;
h = 60*h;
if( h<0 ) h = h+360;
}
phls[0] = h;
phls[1] = l;
phls[2] = s;
}
word hlstorgb( float *phls )
{
float h = phls[0];
float l = phls[1];
float s = phls[2];
float r,g,b;
float m1,m2;
if( l<=0.5f )
m2 = l*(1+s);
else
m2= l+s-l*s;
m1 = 2*l-m2;
// check for zero saturation
if( s== 0 )
{
if( h==-1 )
r = g = b = l;
else
outputdebugstring( "error in hlstorgb. incorrect hls input./n" );
}
else
{
// determine the rgb
r = subhlstorgb( (int)h+120,m1,m2 );
g = subhlstorgb( (int)h,m1,m2 );
b = subhlstorgb( (int)h-120,m1,m2 );
}
int r=(int)(r*255);
int g=(int)(g*255);
int b=(int)(b*255);
return (r>>3<<11)|(g>>2<<5)|(b>>3);
}
float subhlstorgb( int h, float m1, float m2 )
{
h = h%360;
if( h<0 ) h+= 360;
if( h>360 ) h-=360;
if( h<60 ) return m1+(m2-m1)*h/60;
else if( h<180 ) return m2;
else if( h<240 ) return m1+(m2-m1)*(240-h)/60;
else if( h<=360 ) return m1;
return 0.0f;
}
发表者:jiangyunfeng
推荐:
向世明的《数字图象处理》,很不错哦!
发表者:robothn
去找cximage 的源码看吧
http://www.codeproject.com/bitmap/cximage.asp?target=cximage
发表者:kodo
http://asp.6to23.com/iseesoft/now.htm
到isee网站上面去看看
应该可以找得到的
发表者:bruce5260
思路你可以参考digital image processing.大概要用到直方图均衡,在那本书的前几章里头.
发表者:happyandy
去钩钩了!
本文转自
http://www.poptool.net/software/p139/A13917065.shtml