Home > Software engineering >  How to realize the photoshop hue adjustment function
How to realize the photoshop hue adjustment function

Time:09-24

How to implement, in RGB mode in photoshop hue adjustment calculation (hue)?

CodePudding user response:

 
//
Void HSL2RGB (int hue, double saturation, double lightness, BYTE & amp; Red, BYTE & amp; Green, BYTE & amp; Blue)
{
If (saturation==0)
{
Red=green=blue=(BYTE) (lightness * 255);
}
The else
{
Double m1, m2,
If (lightness & lt;=0.5)
M2=lightness + lightness * saturation;
The else
M2=lightness + saturation - lightness * saturation;
//
M1=2 * lightness - m2;
Red=ByteValue (m1, m2, hue + 120);
Green=ByteValue (m1, m2, hue);
Blue=ByteValue (m1, m2, hue - 120);
}
}
Typedef enum {Red, Green, Blue};

BOOL RGB2HLS (BYTE red, BYTE green, BYTE blue, int & amp; Hue, double & amp; Saturation, double & amp; Lightness)
{
Double mn, mx;
Int major;
If (red & lt; Green)
{
Mn=red; Mx=green; Major=Green;
}
The else
{
Mn=green; Mx=red; Major=Red;
}
//
If (blue & lt; Mn)
{
Mn=blue;
}
Else if (blue & gt; Mx)
{
Mx=blue; Major=Blue;
}
//
If (mn==mx)
{
Lightness=mn/255;
Saturation=0;
Hue=240;//?? 0;
}
The else
{
Lightness=(mn + mx)/510;//2 * 255
If (lightness & lt;=0.5) saturation=(double) (mx - mn)/(double) (mn + mx);
The else saturation=(double) (mx - mn)/(double) (510 - mn - mx);
The switch (major)
{
Case Red:
Hue=(int) (* 60 (green, blue)/(mx - mn) + 360);
break;
Case Green:
Hue=(int) ((blue - red) * 60/(mx - mn) + 120);
break;
Case Blue:
Hue=(int) (60/(red, green) * (mx - mn) + 240);
break;
}
If (hue & gt;=360) hue -=360;
}
If (mn==0 & amp; & Mx==255) return TRUE;
The else return FALSE;
}
//
BYTE ByteValue (double m1, m2, double double hue)
{
If (hue> Hue - 360)=360;
Else if (hue//
If (hueElse if (hue<180) m1=m2;
Else if (hue<240) m1=m1 + (m2 - m1) * (240 - hue)/60;
//
Return (BYTE) (m1 * 255);
}

CodePudding user response:

Only through into an HSL calculation? Such as saturation, lightness can be directly calculated in RGB mode (https://blog.csdn.net/xingyanxiao/article/details/48035537), which have similar principle hue adjustment? Back and forth between RGB and an HSL conversion efficiency is too low,

CodePudding user response:

The same does not necessarily 'color RGB

CodePudding user response:

reference schlafenhamster reply: 3/f
RGB same does not necessarily 'color'

Are you saying that the infrared, ultraviolet, gamma rays,... "Color"?

CodePudding user response:

http://www.doc88.com/p-9973777316277.html
"Introduction to color management chapter 2 colour"

CodePudding user response:

The major difference between "Adobe RGB and sRGB color space"
https://blog.csdn.net/self_mind/article/details/50801140

CodePudding user response:

I have just seen in photoshop, adjustable H, maximum and minimum RGB values, only the middle value, in the key of H by example, if the value is below the maximum, then the minor and transferred to the hour, next to raise, each color 60 degrees, divide, and so on, so efficiency should be a little bit high, so large amounts of data, and apply
  • Related