Skip to content

Commit

Permalink
Merge pull request #94 from joshbernfeld/white-balance
Browse files Browse the repository at this point in the history
Added White Balance support
  • Loading branch information
BradLarson authored Feb 17, 2024
2 parents e9258bd + 766ec78 commit d703ea5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
20 changes: 10 additions & 10 deletions examples/Mac/FilterShowcase/FilterShowcase/FilterOperations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ let filterOperations: Array<FilterOperationInterface> = [
},
filterOperationType:.singleInput
),
// FilterOperation(
// filter:{WhiteBalance()},
// listName:"White balance",
// titleName:"White Balance",
// sliderConfiguration:.enabled(minimumValue:2500.0, maximumValue:7500.0, initialValue:5000.0),
// sliderUpdateCallback: {(filter, sliderValue) in
// filter.temperature = sliderValue
// },
// filterOperationType:.singleInput
// ),
FilterOperation(
filter:{WhiteBalance()},
listName:"White balance",
titleName:"White Balance",
sliderConfiguration:.enabled(minimumValue:2500.0, maximumValue:7500.0, initialValue:5000.0),
sliderUpdateCallback: {(filter, sliderValue) in
filter.temperature = sliderValue
},
filterOperationType:.singleInput
),
FilterOperation(
filter:{MonochromeFilter()},
listName:"Monochrome",
Expand Down
8 changes: 8 additions & 0 deletions framework/GPUImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
1F1A90B424BEC03D0029813E /* WhiteBalance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C992101015700A3B43A /* WhiteBalance.swift */; };
1F1A90B524BEC03D0029813E /* WhiteBalance.metal in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C9C2101016100A3B43A /* WhiteBalance.metal */; };
1F1A90B624BEC03D0029813E /* WhiteBalance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C992101015700A3B43A /* WhiteBalance.swift */; };
1F1A90B724BEC03D0029813E /* WhiteBalance.metal in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C9C2101016100A3B43A /* WhiteBalance.metal */; };
4C280F76213426D6001A985C /* Posterize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F75213426D6001A985C /* Posterize.swift */; };
4C280F77213426D6001A985C /* Posterize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F75213426D6001A985C /* Posterize.swift */; };
4C280F79213426EC001A985C /* Posterize.metal in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F78213426EC001A985C /* Posterize.metal */; };
Expand Down Expand Up @@ -1110,6 +1114,7 @@
795ECAA521ED2549000EF927 /* ThresholdSobelEdgeDetection.metal in Sources */,
7954BF462214965D008402A6 /* PinchDistortion.swift in Sources */,
795ECAB121ED2E58000EF927 /* ThresholdSketch.metal in Sources */,
1F1A90B424BEC03D0029813E /* WhiteBalance.swift in Sources */,
79DD50CD213454A2004EF308 /* Vignette.metal in Sources */,
BC9294AA210513DF006C8E93 /* SepiaToneFilter.swift in Sources */,
79DD50C4213450BE004EF308 /* SwirlDistortion.swift in Sources */,
Expand Down Expand Up @@ -1174,6 +1179,7 @@
793D934120F693AD008A7A6E /* GammaAdjustment.swift in Sources */,
BCCFEA6222AEEDDB00C9F4CC /* Camera.swift in Sources */,
79A81CA62101266600A3B43A /* HighlightAndShadowTint.swift in Sources */,
1F1A90B524BEC03D0029813E /* WhiteBalance.metal in Sources */,
79CB6E38210A0EDE0042F87B /* SourceOverBlend.metal in Sources */,
79CB6DD22108B3F00042F87B /* ColorDodgeBlend.swift in Sources */,
79EB1B6E2125C7670049135E /* LookupFilter.metal in Sources */,
Expand Down Expand Up @@ -1315,6 +1321,7 @@
795ECAA621ED2549000EF927 /* ThresholdSobelEdgeDetection.metal in Sources */,
795ECAB221ED2E58000EF927 /* ThresholdSketch.metal in Sources */,
7954BF472214965D008402A6 /* PinchDistortion.swift in Sources */,
1F1A90B624BEC03D0029813E /* WhiteBalance.swift in Sources */,
79DD50CE213454A2004EF308 /* Vignette.metal in Sources */,
BC9294AB210513DF006C8E93 /* SepiaToneFilter.swift in Sources */,
79DD50C5213450BE004EF308 /* SwirlDistortion.swift in Sources */,
Expand Down Expand Up @@ -1379,6 +1386,7 @@
793D933620F68C1B008A7A6E /* ContrastAdjustment.swift in Sources */,
BCCFEA6322AEEDDB00C9F4CC /* Camera.swift in Sources */,
79E30E6D20F118CD005FA13C /* Texture.swift in Sources */,
1F1A90B724BEC03D0029813E /* WhiteBalance.metal in Sources */,
79A81CA72101266600A3B43A /* HighlightAndShadowTint.swift in Sources */,
BC7BA29420F6F2CB006B5F4B /* BrightnessAdjustment.metal in Sources */,
79CB6E39210A0EDE0042F87B /* SourceOverBlend.metal in Sources */,
Expand Down
5 changes: 2 additions & 3 deletions framework/Source/Operations/WhiteBalance.metal
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
using namespace metal;

constant half3 warmFilter = half3(0.93, 0.54, 0.0);

constant half3x3 RGBtoYIQ = half3x3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);
constant half3x3 YIQtoRGB = half3x3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);
constant half3x3 RGBtoYIQ = half3x3(half3(0.299, 0.587, 0.114), half3(0.596, -0.274, -0.322), half3(0.212, -0.523, 0.311));
constant half3x3 YIQtoRGB = half3x3(half3(1.0, 0.956, 0.621), half3(1.0, -0.272, -0.647), half3(1.0, -1.105, 1.702));

typedef struct
{
Expand Down
6 changes: 2 additions & 4 deletions framework/Source/Operations/WhiteBalance.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/*
public class WhiteBalance: BasicOperation {
public var temperature:Float = 5000.0 { didSet { uniformSettings["temperature"] = temperature < 5000.0 ? 0.0004 * (temperature - 5000.0) : 0.00006 * (temperature - 5000.0) } }
public var tint:Float = 0.0 { didSet { uniformSettings["tint"] = tint / 100.0 } }

public init() {
super.init(fragmentFunctionName:"whiteBalanceFragmentShader", numberOfInputs:1)

uniformSettings.appendUniform(5000.0)
uniformSettings.appendUniform(0.0)
({temperature = 5000.0})()
({tint = 0.0})()
}
}
*/

0 comments on commit d703ea5

Please sign in to comment.