ACME-1236 : WIP : Added a min value to vignette
parent
1b5fb66292
commit
35e30759c8
|
|
@ -97,8 +97,8 @@ static const char USAGE[] = "\n"
|
|||
" - 'darken' substracts <param> light to the image (<param> between 0 and 255).\n"
|
||||
" - 'linearize' optimizes the contrast using the brightness histogram. <param> is the fraction (between 0.0 and 1.0) of discarded tail of the histogram.\n"
|
||||
" - 'posterize' redistributes the colors between <param> classes per channel (<param> between 2 and 255).\n"
|
||||
" -v, --vignette <name> [<feather>]\n"
|
||||
" Apply a circular central vignette <name> to the filter using the optional <feather> value. Admissible names:\n"
|
||||
" -v, --vignette <name> [<feather> <min>]\n"
|
||||
" Apply a circular central vignette <name> to the filter using the optional <feather> and <min> values. Admissible names:\n"
|
||||
" - 'blend' : the filter is applied with full intensity in the center and blends with the image to the periphery.\n"
|
||||
" - 'fade' : the filter is applied with full intensity in the center and fades to black to the periphery.\n"
|
||||
" -log, --logmetrics <metric>\n"
|
||||
|
|
@ -371,7 +371,8 @@ int main(int argc, char** argv)
|
|||
std::string filter_name = "";
|
||||
double filter_param = 0.0;
|
||||
std::string vignette_name = "";
|
||||
double vignette_param = 1.0;
|
||||
double vignette_param_1 = 1.0;
|
||||
double vignette_param_2 = 0.0;
|
||||
|
||||
// Init whatever is necessary
|
||||
ll_init_apr();
|
||||
|
|
@ -591,15 +592,23 @@ int main(int argc, char** argv)
|
|||
arg += 1; // Skip that arg now we know it's a valid vignette name
|
||||
if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list
|
||||
break;
|
||||
// --vignette can also have an optional parameter
|
||||
// --vignette can also have optional parameters
|
||||
std::string value_str;
|
||||
value_str = argv[arg+1]; // Check the next arg
|
||||
if (value_str[0] != '-') // If it's not another argument, it's a vignette parameter value
|
||||
{
|
||||
vignette_param = atof(value_str.c_str());
|
||||
vignette_param_1 = atof(value_str.c_str());
|
||||
arg += 1; // Skip that arg now we used it as a valid vignette param
|
||||
if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list
|
||||
break;
|
||||
value_str = argv[arg+1]; // Check the next arg
|
||||
if (value_str[0] != '-') // If it's not another argument, it's a vignette parameter value
|
||||
{
|
||||
vignette_param_2 = atof(value_str.c_str());
|
||||
arg += 1; // Skip that arg now we used it as a valid vignette param
|
||||
if ((arg + 1) == argc) // Break out of the loop if we reach the end of the arg list
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -652,11 +661,11 @@ int main(int argc, char** argv)
|
|||
// Set the vignette if any
|
||||
if (vignette_name == "blend")
|
||||
{
|
||||
raw_image->setVignette(VIGNETTE_MODE_BLEND,(float)(vignette_param));
|
||||
raw_image->setVignette(VIGNETTE_MODE_BLEND,(float)(vignette_param_1),(float)(vignette_param_2));
|
||||
}
|
||||
else if (vignette_name == "fade")
|
||||
{
|
||||
raw_image->setVignette(VIGNETTE_MODE_FADE,(float)(vignette_param));
|
||||
raw_image->setVignette(VIGNETTE_MODE_FADE,(float)(vignette_param_1),(float)(vignette_param_2));
|
||||
}
|
||||
|
||||
// Apply filter if any
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ LLImageBase::LLImageBase()
|
|||
mHistoBlue(NULL),
|
||||
mHistoBrightness(NULL),
|
||||
mVignetteMode(VIGNETTE_MODE_NONE),
|
||||
mVignetteGamma(1.0)
|
||||
mVignetteGamma(1.0),
|
||||
mVignetteMin(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1280,10 +1281,11 @@ void LLImageRaw::colorCorrect(const U8* lut_red, const U8* lut_green, const U8*
|
|||
}
|
||||
}
|
||||
|
||||
void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma)
|
||||
void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma, F32 min)
|
||||
{
|
||||
mVignetteMode = mode;
|
||||
mVignetteGamma = gamma;
|
||||
mVignetteMin = llclampf(min);
|
||||
// We always center the vignette on the image and fits it in the image smallest dimension
|
||||
mVignetteCenterX = getWidth()/2;
|
||||
mVignetteCenterY = getHeight()/2;
|
||||
|
|
@ -1293,9 +1295,11 @@ void LLImageRaw::setVignette(EVignetteMode mode, F32 gamma)
|
|||
F32 LLImageRaw::getVignetteAlpha(S32 i, S32 j)
|
||||
{
|
||||
// alpha is a modified gaussian value, with a center and fading in a circular pattern toward the edges
|
||||
// the gamma parameter controls the intensity of the drop down from alpha 1.0 to 0.0
|
||||
// The gamma parameter controls the intensity of the drop down from alpha 1.0 (center) to 0.0
|
||||
F32 d_center_square = (i - mVignetteCenterX)*(i - mVignetteCenterX) + (j - mVignetteCenterY)*(j - mVignetteCenterY);
|
||||
return powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
|
||||
F32 alpha = powf(F_E, -(powf((d_center_square/(mVignetteWidth*mVignetteWidth)),mVignetteGamma)/2.0f));
|
||||
// We rescale alpha between min and 1.0 so to avoid complete fading if so desired.
|
||||
return (mVignetteMin + alpha * (1.0 - mVignetteMin));
|
||||
}
|
||||
|
||||
U32* LLImageRaw::getBrightnessHistogram()
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ protected:
|
|||
S32 mVignetteCenterY;
|
||||
S32 mVignetteWidth;
|
||||
F32 mVignetteGamma;
|
||||
F32 mVignetteMin;
|
||||
|
||||
public:
|
||||
static void generateMip(const U8 *indata, U8* mipdata, int width, int height, S32 nchannels);
|
||||
|
|
@ -292,7 +293,7 @@ public:
|
|||
// Filter Primitives
|
||||
void colorTransform(const LLMatrix3 &transform);
|
||||
void colorCorrect(const U8* lut_red, const U8* lut_green, const U8* lut_blue);
|
||||
void setVignette(EVignetteMode mode, F32 gamma);
|
||||
void setVignette(EVignetteMode mode, F32 gamma, F32 min);
|
||||
U32* getBrightnessHistogram();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Reference in New Issue