Guidance:
August 23 rd, 2007 by admin
I am not very familiar with VC, so I will not do it myself.
The netizen replied:
Sender: sunrise
Go to Intel's website to see the image processing library.
Issuer: serenade
// Adjust the color, brightness, and saturation of the image
// Prepared by: shenqu on Wu menghua csdn
// Wondertop@263.net
// 2003-3-1
// Usage: using the changehls function, the image cannot contain pitch.
// This function is consistent with the hue/saturation operation in Photoshop, and the value range is the same.
// The image must be 565
// Currently, only color change has been tested. If you have any other questions, contact me.
Void changehls (word * pwimagebuf, int width, int height, int hue,
Int lig, int SAT)
{
Float liglow = 0;
Float lighigh = 1;
If (LIG lighigh = 1 + Lig/100366f;
Else if (LIG> 0)
Liglow = Lig/100366f;
Float satlow = 0;
Float sathigh = 1;
If (Sat sathigh = 1 + SAT/100366f;
Else if (Sat> 0)
Satlow = SAT/100366f;
Int Index = 0;
Float HLS [3];
Word Color = 0 xFFFF;
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] 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 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}
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 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> 2> 3 );
}
Float subhlstorgb (int h, float M1, float m2)
{
H = H % 360;
If (H If (h> 360) H-= 360;
If (H else if (H
Return 0.0f;
}
Sender: jiangyunfeng
Recommended:
Xiang Shiming's digital image processing is awesome!
Table issuer: robothn
Go to the cximage source code.
Http://www.codeproject.com/bitmap/cximage.asp? Target = cximage
Table issuer: Kodo
Http://asp.6to23.com/iseesoft/now.htm
Visit the isee website.
You can find
Issuer: bruce5260
You can refer to digital image processing. histogram balancing is generally used in the first few chapters of this book.
Sender: happyandy
I checked it!
This article is transferred from
Http://www.poptool.net/software/p139/A13917065.shtml