Skip to content

Commit

Permalink
Merge pull request #243 from norbertrostaing/master
Browse files Browse the repository at this point in the history
add hue saturation and brightness in filter extract
  • Loading branch information
benkuper authored Aug 7, 2024
2 parents 6d1c879 + 9458be2 commit d50aa16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ Parameter* SimpleConversionFilter::setupSingleParameterInternal(Parameter* sourc

addExtraRetargetOptions();

if (dynamic_cast<ColorParameter*>(retargetP) != nullptr) retargetComponent->addOption("Hue", HUE)->addOption("Saturation", SATURATION)->addOption("Brightness", BRIGHTNESS);
if (transferType == EXTRACT) retargetComponent->addOption("Min", MIN)->addOption("Max", MAX)->addOption("Average", AVERAGE)->addOption("Length", LENGTH)->addOption("Area", AREA);


if (useBaseValue)
{
if (transferType == TARGET)
Expand Down Expand Up @@ -272,6 +272,27 @@ MappingFilter::ProcessResult SimpleConversionFilter::processSingleParameterInter
val = 1;
for (int i = 0; i < source->value.size(); i++) val = (float)val * (float)source->value[i];
break;

case HUE:
{
ColorParameter* colorParam = dynamic_cast<ColorParameter*>(source);
val = colorParam->getColor().getHue();
break;
}

case SATURATION:
{
ColorParameter* colorParam = dynamic_cast<ColorParameter*>(source);
val = colorParam->getColor().getSaturation();
break;
}

case BRIGHTNESS:
{
ColorParameter* colorParam = dynamic_cast<ColorParameter*>(source);
val = colorParam->getColor().getBrightness();
break;
}

default:
if (targetData < source->value.size()) val = source->value[targetData];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SimpleConversionFilter :
enum TransferType { DIRECT, EXTRACT, MERGE, TARGET};
TransferType transferType;

enum ExtractOption { MIN = 100, MAX = 101, AVERAGE = 102, LENGTH = 103, AREA = 104 };
enum ExtractOption { MIN = 100, MAX = 101, AVERAGE = 102, LENGTH = 103, AREA = 104, HUE = 105, SATURATION = 106, BRIGHTNESS = 107 };

virtual void setupParametersInternal(int mutiplexIndex, bool rangeOnly = false) override;
virtual Parameter* setupSingleParameterInternal(Parameter* source, int multiplexIndex, bool rangeOnly) override;
Expand Down

0 comments on commit d50aa16

Please sign in to comment.