Developing Core Image Filters for ios

Size: px
Start display at page:

Download "Developing Core Image Filters for ios"

Transcription

1 Media #WWDC14 Developing Core Image Filters for ios Session 515 Alexandre Naaman Lead Customizer Tony Chu General Specialist 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

2 New to ios 8 Write your own kernels Introduced on OS X 10.4, now on ios Main motivation unable to write kernels as a combination of existing filters Use cases - Per pixel effects (e.g., hot pixels, vignette) - Distortions that cannot be represented as a matrix (Droste)

3 Agenda Concepts

4 Agenda Concepts Examples of writing custom kernels

5 Agenda Concepts Examples of writing custom kernels Platform differences

6 Key Concepts

7 Key Concepts Filters perform per pixel operations on an image Sepia Filter Original Result

8 Key Concepts Filters can be chained together for complex effects Sepia Filter Hue Adjust Filter Contrast Filter Original Result

9 Key Concepts Intermediate images are lightweight objects Sepia Filter Hue Adjust Filter Contrast Filter Original Result

10 Key Concepts Each filter has one or more kernel functions Sepia Filter Hue Adjust Filter Contrast Filter Original Result kernel vec4 sepia ( kernel vec4 hue ( kernel vec4 contrast (

11 Key Concepts Kernels concatenated into programs to minimize buffers Concat d Contrast Sepia Filter Original Result kernel vec4 sepia ( kernel vec4 hue ( kernel vec4 contrast (

12 Key Concepts Kernels concatenated into programs to minimize buffers Concat d Contrast Sepia Filter Original Result kernel vec4 sepia ( kernel vec4 hue ( kernel vec4 contrast (

13 Core Image Classes

14 Core Image Classes CIKernel Represents a program written in Core Image s kernel language

15 Core Image Classes CIKernel Represents a program written in Core Image s kernel language CIFilter Has mutable input parameters Uses one or more CIKernels to make a new image based on inputs

16 Core Image Classes CIKernel Represents a program written in Core Image s kernel language CIFilter Has mutable input parameters Uses one or more CIKernels to make a new image based on inputs CIImage An immutable object that represents the recipe for an image Non zero origin (lower left) and possibly infinite bounds

17 Core Image Classes CIKernel Represents a program written in Core Image s kernel language CIFilter Has mutable input parameters Uses one or more CIKernels to make a new image based on inputs CIImage An immutable object that represents the recipe for an image Non zero origin (lower left) and possibly infinite bounds CIContext A object through which Core Image draws results

18 Concepts Starting assumptions void *inputbuffer={ };

19 Concepts Starting assumptions void *inputbuffer={ }; void *outputbuffer={ };

20 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } void *outputbuffer={ };

21 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ void *outputbuffer={ };

22 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ };

23 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ };

24 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ }; CIKernel: processpixel

25 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ }; CIKernel: processpixel CIFilter subclass

26 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ }; CIImage CIKernel: processpixel CIFilter subclass

27 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ }; CIImage other input params CIKernel: processpixel CIFilter subclass

28 Concepts Starting assumptions void *inputbuffer={ }; for (j=0;j<height;j++){ } } for (i=0;i<width;i++){ outputbuffer[i][j]= processpixel (inputbuffer[i][j]); void *outputbuffer={ }; CIImage other input params CIKernel: processpixel CIFilter subclass CIImage

29 Workflow Using Core Image on ios

30 Workflow Using Core Image on ios Create input CIImages

31 Workflow Using Core Image on ios Create input CIImages Subclass CIFilter

32 Workflow Using Core Image on ios Create input CIImages Subclass CIFilter Get output CIImage

33 Workflow Using Core Image on ios Create input CIImages Subclass CIFilter Get output CIImage Use CIContext to render output image (to CGImageRef, EAGL context, etc.)

34 Workflow Using Core Image on ios Create input CIImages Subclass CIFilter Create kernel Apply kernel to input image(s) and pass parameters from filter Get output CIImage Use CIContext to render output image (to CGImageRef, EAGL context, etc.)

35 115 Built-in CIFilters on ios CIAccordianFoldTransition CIAdditionCompositing CIAffineClamp CIAffineTile CIAffineTransform CIAreaHistogram CIBarsSwipeTransition CIBlendWithMask CIBloom CIBumpDistortion CIBumpDistortionLinear CICheckerboardGenerator CICircleSplashDistortion CICircularScreen CICode128BarcodeGenerator CIColorBlendMode CIColorBurnBlendMode CIColorControls CIColorCube CIColorDodgeBlendMode CIColorInvert CIColorMap CIColorMatrix CIColorMonochrome CIColorClamp CIColorCrossPolynomial CIColorPolynomial CIColorPosterize CIConstantColorGenerator CIConvolution3X3 CIConvolution5X5 CIConvolution9Horizontal CIConvolution9Vertical CICopyMachineTransition CICrop CIDarkenBlendMode CIDifferenceBlendMode CIDisintegrateWithMask CIDissolveTransition CIDivideBlendMode CIDotScreen CIEightfoldReflectedTile CIExclusionBlendMode CIExposureAdjust CIFalseColor CIFlashTransition CIFourfoldReflectedTile CIFourfoldTranslatedTile CIGammaAdjust CIGaussianBlur CIGaussianGradient CIGlassDistortion CIGlideReflectedTile CIGloom CIHardLightBlendMode CIHatchedScreen CIHighlightShadowAdjust CIHistogramDisplayFilter CIHoleDistortion CIHueAdjust CIHueBlendMode CILanczosScaleTransform CILightenBlendMode CILightTunnel CILinearBurnBlendMode CILinearDodgeBlendMode CILinearGradient CILineScreen CILuminosityBlendMode CIMaskToAlpha CIMaximumComponent CIMaximumCompositing CIMinimumComponent CIMinimumCompositing CIModTransition CIMultiplyBlendMode CIMultiplyCompositing CIOverlayBlendMode CIPerspectiveCorrection CIPerspectiveTile CIPerspectiveTransform CIPinchDistortion CIPinLightBlendMode CIPixellate CIRadialGradient CIRandomGenerator CISaturationBlendMode CIScreenBlendMode CISepiaTone CISharpenLuminance CISixfoldReflectedTile CISixfoldRotatedTile CISoftLightBlendMode CISourceAtopCompositing CILinearToSRGBToneCurve CISRGBToneCurveToLinear CISourceInCompositing CISourceOutCompositing CISourceOverCompositing CIStarShineGenerator CIStraightenFilter CIStripesGenerator CISubtractBlendMode CISwipeTransition CITemperatureAndTint CIToneCurve CITriangleKaleidoscope CITwelvefoldReflectedTile CITwirlDistortion CIUnsharpMask CIVibrance CIVignette CIVortexDistortion CIWhitePointAdjust CIQRCodeGenerator

36 115 Built-in CIFilters on ios (78 Color) CIAccordianFoldTransition CIAdditionCompositing CIAffineClamp CIAffineTile CIAffineTransform CIAreaHistogram CIBarsSwipeTransition CIBlendWithMask CIBloom CIBumpDistortion CIBumpDistortionLinear CICheckerboardGenerator CICircleSplashDistortion CICircularScreen CICode128BarcodeGenerator CIColorBlendMode CIColorBurnBlendMode CIColorControls CIColorCube CIColorDodgeBlendMode CIColorInvert CIColorMap CIColorMatrix CIColorMonochrome CIColorClamp CIColorCrossPolynomial CIColorPolynomial CIColorPosterize CIConstantColorGenerator CIConvolution3X3 CIConvolution5X5 CIConvolution9Horizontal CIConvolution9Vertical CICopyMachineTransition CICrop CIDarkenBlendMode CIDifferenceBlendMode CIDisintegrateWithMask CIDissolveTransition CIDivideBlendMode CIDotScreen CIEightfoldReflectedTile CIExclusionBlendMode CIExposureAdjust CIFalseColor CIFlashTransition CIFourfoldReflectedTile CIFourfoldTranslatedTile CIGammaAdjust CIGaussianBlur CIGaussianGradient CIGlassDistortion CIGlideReflectedTile CIGloom CIHardLightBlendMode CIHatchedScreen CIHighlightShadowAdjust CIHistogramDisplayFilter CIHoleDistortion CIHueAdjust CIHueBlendMode CILanczosScaleTransform CILightenBlendMode CILightTunnel CILinearBurnBlendMode CILinearDodgeBlendMode CILinearGradient CILineScreen CILuminosityBlendMode CIMaskToAlpha CIMaximumComponent CIMaximumCompositing CIMinimumComponent CIMinimumCompositing CIModTransition CIMultiplyBlendMode CIMultiplyCompositing CIOverlayBlendMode CIPerspectiveCorrection CIPerspectiveTile CIPerspectiveTransform CIPinchDistortion CIPinLightBlendMode CIPixellate CIRadialGradient CIRandomGenerator CISaturationBlendMode CIScreenBlendMode CISepiaTone CISharpenLuminance CISixfoldReflectedTile CISixfoldRotatedTile CISoftLightBlendMode CISourceAtopCompositing CILinearToSRGBToneCurve CISRGBToneCurveToLinear CISourceInCompositing CISourceOutCompositing CISourceOverCompositing CIStarShineGenerator CIStraightenFilter CIStripesGenerator CISubtractBlendMode CISwipeTransition CITemperatureAndTint CIToneCurve CITriangleKaleidoscope CITwelvefoldReflectedTile CITwirlDistortion CIUnsharpMask CIVibrance CIVignette CIVortexDistortion CIWhitePointAdjust CIQRCodeGenerator

37 115 Built-in CIFilters on ios (27 Warps) CIAccordianFoldTransition CIAdditionCompositing CIAffineClamp CIAffineTile CIAffineTransform CIAreaHistogram CIBarsSwipeTransition CIBlendWithMask CIBloom CIBumpDistortion CIBumpDistortionLinear CICheckerboardGenerator CICircleSplashDistortion CICircularScreen CICode128BarcodeGenerator CIColorBlendMode CIColorBurnBlendMode CIColorControls CIColorCube CIColorDodgeBlendMode CIColorInvert CIColorMap CIColorMatrix CIColorMonochrome CIColorClamp CIColorCrossPolynomial CIColorPolynomial CIColorPosterize CIConstantColorGenerator CIConvolution3X3 CIConvolution5X5 CIConvolution9Horizontal CIConvolution9Vertical CICopyMachineTransition CICrop CIDarkenBlendMode CIDifferenceBlendMode CIDisintegrateWithMask CIDissolveTransition CIDivideBlendMode CIDotScreen CIEightfoldReflectedTile CIExclusionBlendMode CIExposureAdjust CIFalseColor CIFlashTransition CIFourfoldReflectedTile CIFourfoldTranslatedTile CIGammaAdjust CIGaussianBlur CIGaussianGradient CIGlassDistortion CIGlideReflectedTile CIGloom CIHardLightBlendMode CIHatchedScreen CIHighlightShadowAdjust CIHistogramDisplayFilter CIHoleDistortion CIHueAdjust CIHueBlendMode CILanczosScaleTransform CILightenBlendMode CILightTunnel CILinearBurnBlendMode CILinearDodgeBlendMode CILinearGradient CILineScreen CILuminosityBlendMode CIMaskToAlpha CIMaximumComponent CIMaximumCompositing CIMinimumComponent CIMinimumCompositing CIModTransition CIMultiplyBlendMode CIMultiplyCompositing CIOverlayBlendMode CIPerspectiveCorrection CIPerspectiveTile CIPerspectiveTransform CIPinchDistortion CIPinLightBlendMode CIPixellate CIRadialGradient CIRandomGenerator CISaturationBlendMode CIScreenBlendMode CISepiaTone CISharpenLuminance CISixfoldReflectedTile CISixfoldRotatedTile CISoftLightBlendMode CISourceAtopCompositing CILinearToSRGBToneCurve CISRGBToneCurveToLinear CISourceInCompositing CISourceOutCompositing CISourceOverCompositing CIStarShineGenerator CIStraightenFilter CIStripesGenerator CISubtractBlendMode CISwipeTransition CITemperatureAndTint CIToneCurve CITriangleKaleidoscope CITwelvefoldReflectedTile CITwirlDistortion CIUnsharpMask CIVibrance CIVignette CIVortexDistortion CIWhitePointAdjust CIQRCodeGenerator

38 115 Built-in CIFilters on ios (7 Convolution) CIAccordianFoldTransition CIAdditionCompositing CIAffineClamp CIAffineTile CIAffineTransform CIAreaHistogram CIBarsSwipeTransition CIBlendWithMask CIBloom CIBumpDistortion CIBumpDistortionLinear CICheckerboardGenerator CICircleSplashDistortion CICircularScreen CICode128BarcodeGenerator CIColorBlendMode CIColorBurnBlendMode CIColorControls CIColorCube CIColorDodgeBlendMode CIColorInvert CIColorMap CIColorMatrix CIColorMonochrome CIColorClamp CIColorCrossPolynomial CIColorPolynomial CIColorPosterize CIConstantColorGenerator CIConvolution3X3 CIConvolution5X5 CIConvolution9Horizontal CIConvolution9Vertical CICopyMachineTransition CICrop CIDarkenBlendMode CIDifferenceBlendMode CIDisintegrateWithMask CIDissolveTransition CIDivideBlendMode CIDotScreen CIEightfoldReflectedTile CIExclusionBlendMode CIExposureAdjust CIFalseColor CIFlashTransition CIFourfoldReflectedTile CIFourfoldTranslatedTile CIGammaAdjust CIGaussianBlur CIGaussianGradient CIGlassDistortion CIGlideReflectedTile CIGloom CIHardLightBlendMode CIHatchedScreen CIHighlightShadowAdjust CIHistogramDisplayFilter CIHoleDistortion CIHueAdjust CIHueBlendMode CILanczosScaleTransform CILightenBlendMode CILightTunnel CILinearBurnBlendMode CILinearDodgeBlendMode CILinearGradient CILineScreen CILuminosityBlendMode CIMaskToAlpha CIMaximumComponent CIMaximumCompositing CIMinimumComponent CIMinimumCompositing CIModTransition CIMultiplyBlendMode CIMultiplyCompositing CIOverlayBlendMode CIPerspectiveCorrection CIPerspectiveTile CIPerspectiveTransform CIPinchDistortion CIPinLightBlendMode CIPixellate CIRadialGradient CIRandomGenerator CISaturationBlendMode CIScreenBlendMode CISepiaTone CISharpenLuminance CISixfoldReflectedTile CISixfoldRotatedTile CISoftLightBlendMode CISourceAtopCompositing CILinearToSRGBToneCurve CISRGBToneCurveToLinear CISourceInCompositing CISourceOutCompositing CISourceOverCompositing CIStarShineGenerator CIStraightenFilter CIStripesGenerator CISubtractBlendMode CISwipeTransition CITemperatureAndTint CIToneCurve CITriangleKaleidoscope CITwelvefoldReflectedTile CITwirlDistortion CIUnsharpMask CIVibrance CIVignette CIVortexDistortion CIWhitePointAdjust CIQRCodeGenerator

39 Anatomy of CIKernel OS X and ios CIKernel

40 Anatomy of CIKernel OS X and ios CIKernel ios Only

41 Anatomy of CIKernel OS X and ios CIKernel CIColorKernel CIWarpKernel ios Only

42 Anatomy of CIKernel + (CIKernel *) kernelwithstring:(nsstring *); - (CIImage *) applywithextent:(cgrect)extent roicallback:(cikernelroicallback)callback arguments:(nsarray Performs no actual work

43 Anatomy of CIKernel + (CIKernel *) kernelwithstring:(nsstring *); - (CIImage *) applywithextent:(cgrect)extent roicallback:(cikernelroicallback)callback arguments:(nsarray Performs no actual work GLSL + extensions for imaging Inputs and outputs are floats

44 Color Kernels CIColorKernel

45 Basic Principles of Color Kernels CIColorKernel Input Image(s) CIImage (RGBA8, ARGB8, RGBA Float, RGBA16, etc) CIColorKernel (everything is read as RGBA floats) Output Image CIImage (RGBA Float)

46 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; }

47 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; }

48 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; }

49 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; }

50 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; }

51 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; }

52 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

53 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

54 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

55 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

56 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

57 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

58 Color Kernel Example kernel vec4 donothing ( sample s ) { return s.rgba; } kernel vec4 swapredandgreen ( sample s ) { return s.grba; } kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); }

59 Color Kernel Example Subclassing CIFilter

60 Color Kernel Example Subclassing SwapRedGreenFilter : (retain, nonatomic) CIImage (copy, nonatomic) NSNumber

61 Color Kernel Example Subclassing SwapRedGreenFilter : (retain, nonatomic) CIImage (copy, nonatomic) SwapRedGreenFilter -(CIKernel *)mykernel { } // convenience +(NSDictionary *)customattributes { } -(CIImage *)outputimage {

62 Color Kernel Example Applying the kernel inside of a CIFilter - (CIKernel *) mykernel { static CIColorKernel *kernel = nil; static dispatch_once_t once; dispatch_once(&once, ^{ kernel = [CIColorKernel kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); } ]; }); return kernel; } - (CIImage *)outputimage { CGRect dod = inputimage.extent ; return [ [self mykernel] applywithextent : dod arguments inputamount]]; }

63 Color Kernel Example Applying the kernel inside of a CIFilter - (CIKernel *) mykernel { static CIColorKernel *kernel = nil; static dispatch_once_t once; dispatch_once(&once, ^{ kernel = [CIColorKernel kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); } ]; }); return kernel; } - (CIImage *)outputimage { CGRect dod = inputimage.extent ; return [ [self mykernel] applywithextent : dod arguments inputamount]]; }

64 Color Kernel Example Applying the kernel inside of a CIFilter - (CIKernel *) mykernel { static CIColorKernel *kernel = nil; static dispatch_once_t once; dispatch_once(&once, ^{ kernel = [CIColorKernel kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); } ]; }); return kernel; } - (CIImage *)outputimage { CGRect dod = inputimage.extent ; return [ [self mykernel] applywithextent : dod arguments inputamount]]; }

65 Color Kernel Example Applying the kernel inside of a CIFilter - (CIKernel *) mykernel { static CIColorKernel *kernel = nil; static dispatch_once_t once; dispatch_once(&once, ^{ kernel = [CIColorKernel kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); } ]; }); return kernel; } - (CIImage *)outputimage { CGRect dod = inputimage.extent ; return [ [self mykernel] applywithextent : dod arguments inputamount]]; }

66 Color Kernel Example Applying the kernel inside of a CIFilter - (CIKernel *) mykernel { static CIColorKernel *kernel = nil; static dispatch_once_t once; dispatch_once(&once, ^{ kernel = [CIColorKernel kernel vec4 swapredandgreenamount ( sample s, float amount ) { return mix(s.rgba, s.grba, amount); } ]; }); return kernel; } - (CIImage *)outputimage { CGRect dod = inputimage.extent ; return [ [self mykernel] applywithextent : dod arguments inputamount]]; }

67 Color Kernel Which Depends on Position Vignette effect

68 Color Kernel Which Depends on Position Vignette effect

69 Color Kernel Which Depends on Position Vignette effect 1.0

70 Color Kernel Which Depends on Position Vignette effect

71 Color Kernel Which Depends on Position Vignette effect

72 Color Kernel Which Depends on Position Vignette effect

73 Color Kernel Which Depends on Position Vignette effect

74 Color Kernel Which Depends on Position Vignette effect

75 Color Kernel Which Depends on Position Vignette effect 0.0 x = 1.0

76 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { }

77 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { }

78 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { } x extent.origin

79 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { } x extent.origin

80 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { } x extent.origin

81 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { extent.size/ 2.0 } x extent.origin

82 Color Kernel Which Depends on Position Vignette kernel code kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset extent.size/ 2.0 } x extent.origin

83 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset }

84 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset }

85 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset }

86 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset destcoord() }

87 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 centeroffset destcoord() vecfromcenter kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { }

88 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 vecfromcenter kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset destcoord() vec2 vecfromcenter = destcoord () - centeroffset; }

89 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 vecfromcenter kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset destcoord() vec2 vecfromcenter = destcoord () - centeroffset; float distance = length ( vecfromcenter ) ; }

90 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 vecfromcenter kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset destcoord() vec2 vecfromcenter = destcoord () - centeroffset; float distance = length ( vecfromcenter ) ; float darken = ( distance / radius ) ; }

91 Color Kernel Which Depends on Position Vignette kernel code centeroffset = extent.origin + extent.size/2.0 radius = length ( extent.size )/2.0 vecfromcenter kernel vec4 vignette ( sample s, vec2 centeroffset, float radius ) { centeroffset destcoord() } vec2 vecfromcenter = destcoord () - centeroffset; float distance = length ( vecfromcenter ) ; float darken = ( distance / radius ) ; return vec4 ( s.rgb * darken, s.a ) ;

92 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments }

93 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments }

94 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments }

95 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments }

96 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments }

97 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments } kernel vec4 vignette ( sample s,vec2 centeroffset,float radius){ }

98 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments } kernel vec4 vignette ( sample s,vec2 centeroffset,float radius){ }

99 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments } kernel vec4 vignette ( sample s,vec2 centeroffset,float radius){ }

100 Color Kernel Which Depends on Position Vignette outputimage method - (CIImage *)outputimage { CGRect dod = inputimage.extent; double radius = 0.5 * hypot ( dod.size.width, dod.size.height ); CIVector *centeroffset = [CIVector vectorwithx : dod.size.width * dod.origin.x Y : dod.size.height * dod.origin.y]; return [[self mykernel] applywithextent : dod arguments } kernel vec4 vignette ( sample s,vec2 centeroffset,float radius){ }

101 DOD for Source over Compositing Kernel Non zero pixels kernel vec4 sourceover( sample src, sample dest ) { return src + (1.0-src.a)*dest; } CGRect dod = CGRectUnion ( inputimage.extent, inputbackgroundimage.extent )

102 DOD for Source over Compositing Kernel Non zero pixels kernel vec4 sourceover( sample src, sample dest ) { return src + (1.0-src.a)*dest; } CGRect dod = CGRectUnion ( inputimage.extent, inputbackgroundimage.extent )

103 Warp Kernels CIWarpKernel

104 Basic Principles of Warp Kernels CIWarpKernel Specify DOD and ROI block callback Input Position (vec2) CIWarpKernel Output Position (vec2)

105 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 donothing () { return destcoord(); } y input image x

106 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 donothing () { return destcoord(); } y input image y output image x x

107 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 donothing () { return destcoord(); } y input image y output image destcoord() x x

108 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 donothing () { return destcoord(); } y input image y output image destcoord() x x

109 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y x x

110 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y x x

111 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() x x

112 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() x x

113 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() x x x

114 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() x x x imagewidth

115 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() x x x imagewidth imagewidth-x

116 Basic Principles of Warp Kernels CIWarpKernel think backwards kernel vec2 mirrorx ( float imagewidth ) { vec2 input = destcoord(); return vec2 ( imagewidth - input.x, input.y ); } y y destcoord() imagewidth-x x x imagewidth x imagewidth-x

117 Invoking MirrorX Kernel CIWarpKernel *kernel = [CIWarpKernel kernelwithstring:kernelsourcecode]; - (CIImage *) outputimage { CGFloat inputwidth = inputimage.extent.size.width; } CIImage *result = [[self mykernel] applywithextent: inputimage.extent roicallback: ^( int index, CGRect r ) { } inputimage: inputimage return result;

118 Invoking MirrorX Kernel CIWarpKernel *kernel = [CIWarpKernel kernelwithstring:kernelsourcecode]; - (CIImage *) outputimage { CGFloat inputwidth = inputimage.extent.size.width; } CIImage *result = [[self mykernel] applywithextent: inputimage.extent roicallback: ^( int index, CGRect r ) { } inputimage: inputimage return result;

119 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI 5

120 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI

121 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI 5 5

122 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI 5 5 CGRectMake (,,, );

123 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 x x CGRectMake (,,, );

124 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 x r.size.width x CGRectMake (,, r.size.width, );

125 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height x r.size.width x CGRectMake (,, r.size.width, r.size.height);

126 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height r.origin.y x r.size.width x CGRectMake (, r.origin.y, r.size.width, r.size.height);

127 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height r.origin.y neworigin x r.size.width x CGRectMake ( neworigin, r.origin.y, r.size.width, r.size.height);

128 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height r.origin.y neworigin x r.size.width x CGRectMake ( neworigin, r.origin.y, r.size.width, r.size.height); neworigin =

129 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height r.origin.y neworigin x r.size.width x inputimage.extent.size.width CGRectMake ( neworigin, r.origin.y, r.size.width, r.size.height); neworigin = inputimage.extent.size.width

130 Basic Principles of Warp Kernels For output rect, what part of input rect do we need ROI y y 5 5 r.size.height r.origin.y neworigin x r.origin.x r.size.width x inputimage.extent.size.width CGRectMake ( neworigin, r.origin.y, r.size.width, r.size.height); neworigin = inputimage.extent.size.width - ( r.origin.x + r.size.width );

131 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

132 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

133 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

134 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

135 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

136 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

137 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

138 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

139 Invoking MirrorX Kernel - (CIImage *) outputimage { if ( CGRectIsInfinite ( inputimage.extent ) ) return nil; CGPoint o = inputimage.extent.origin; CGFloat inputwidth = inputimage.extent.size.width; CGAffineTransform to = CGAffineTransformMakeTranslation ( -o.x, -o.y ); CIImage *result = [inputimage imagebyapplyingtransform:to]; result = [[self mykernel] applywithextent: ]; // same as before CGAffineTransform from = CGAffineTransformMakeTranslation ( o.x, o.y ); } return [result imagebyapplyingtransform:from];

140 More Complex Warp Kernel Anamorphic stretch

141 More Complex Warp Kernel Anamorphic stretch 1024

142 More Complex Warp Kernel Anamorphic stretch

143 More Complex Warp Kernel Anamorphic stretch

144 More Complex Warp Kernel Anamorphic stretch

145 More Complex Warp Kernel Anamorphic stretch

146 sourcetodest() and desttosource() Invertible functions

147 sourcetodest() and desttosource() Invertible functions f(x) x

148 sourcetodest() and desttosource() Invertible functions f(x) - width/2 width/2 x

149 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 - width/2 width/2 x

150 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 f(xi)==xi - width/2 xi width/2 x

151 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 f(xi)==xi - width/2 xi width/2 x

152 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 f(xi)==xi - width/2 xi width/2 x

153 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 - width/2 width/2 x DOD

154 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 dest x - width/2 src x width/2 x DOD

155 sourcetodest() and desttosource() Invertible functions f(x) scale = 1 dest x src x dest x - width/2 src x width/2 x DOD Kernel and ROI

156 sourcetodest() and desttosource() Invertible functions scale = desiredwidth/inputwidth k = inputwidth/(1.0 - (1.0/scale))

157 sourcetodest() and desttosource() Invertible functions scale = desiredwidth/inputwidth k = inputwidth/(1.0 - (1.0/scale)) sourcetodest (1024) == 1280 desttosource (1280) == 1024

158 Kernel kernel vec2 strech (float center, float k) { vec2 p = destcoord(); return p; }

159 Kernel kernel vec2 strech (float center, float k) { vec2 p = destcoord(); return p; }

160 Kernel kernel vec2 strech (float center, float k) { vec2 p = destcoord(); p.x -= center; return p; }

161 Kernel kernel vec2 strech (float center, float k) { vec2 p = destcoord(); p.x -= center; p.x = p.x / (1.0 + abs(p.x / k)); p.x += center; return p; }

162 ROI Pseudocode r

163 ROI Pseudocode r r

164 ROI Pseudocode r r leftp = r.origin.x

165 ROI Pseudocode r r leftp = r.origin.x

166 ROI Pseudocode r r leftp = r.origin.x leftp = desttosource ( leftp )

167 ROI Pseudocode r r leftp = r.origin.x rightp = r.origin.x + r.size.width leftp = desttosource ( leftp )

168 ROI Pseudocode r r leftp = r.origin.x rightp = r.origin.x + r.size.width leftp = desttosource ( leftp )

169 ROI Pseudocode r r leftp = r.origin.x rightp = r.origin.x + r.size.width leftp = desttosource ( leftp ) rightp = desttosource ( rightp )

170 ROI Pseudocode r r leftp = r.origin.x rightp = r.origin.x + r.size.width leftp = desttosource ( leftp ) rightp = desttosource ( rightp ) newwidth = rightp - leftp r = CGRectMake ( leftp, r.origin.y, newwidth, r.size.height )

171 ROI Region of Interest Re-use kernel equation double desttosource(double x, double center, double k) { } return x;

172 ROI Region of Interest Re-use kernel equation double desttosource(double x, double center, double k) { } return x;

173 ROI Region of Interest Re-use kernel equation double desttosource(double x, double center, double k) { x -= center; x = x / (1.0 + fabs(x / k)); x += center; } return x;

174 ROI Region of Interest Re-use kernel equation double desttosource(double x, double center, double k) { x -= center; x = x / (1.0 + fabs(x / k)); x += center; } return x; CGRect regionof (CGRect r, float center, float k) { double leftp = desttosource (r.origin.x, center, k); double rightp = desttosource (r.origin.x + r.size.width, center, k); return CGRectMake (leftp, r.origin.y, rightp-leftp, r.size.height); }

175 DOD Domain of Definition double sourcetodest (double x, double center, double k) { x -= center; x = x / (1.0 - fabs(x / k)); x += center; } return x;

176 DOD Domain of Definition double sourcetodest (double x, double center, double k) { x -= center; x = x / (1.0 - fabs(x / k)); x += center; } return x; CGRect dodforinputrect (CGRect r, double center, double k) { double leftp = sourcetodest (r.origin.x, center, k); double rightp = sourcetodest (r.origin.x + r.size.width, center, k); return CGRectMake (leftp, r.origin.y, rightp-leftp, r.size.height); }

177 outputimage Method - (CIImage *) outputimage { double inputwidth = inputimage.extent.size.width; double k = inputwidth / ( / [inputscale floatvalue] ); double center = inputimage.extent.origin.x + inputwidth / 2.0; CGRect dod = dodforinputrect (inputimage.extent, center, k); } CIImage * result = [[self mykernel] applywithextent: dod roicallback: ^(int index, CGRect rect) { return regionof(rect, center, k); } inputimage: return result;

178 outputimage Method - (CIImage *) outputimage { double inputwidth = inputimage.extent.size.width; double k = inputwidth / ( / [inputscale floatvalue] ); double center = inputimage.extent.origin.x + inputwidth / 2.0; CGRect dod = dodforinputrect (inputimage.extent, center, k); } CIImage * result = [[self mykernel] applywithextent: dod roicallback: ^(int index, CGRect rect) { return regionof(rect, center, k); } inputimage: return result;

179 outputimage Method - (CIImage *) outputimage { double inputwidth = inputimage.extent.size.width; double k = inputwidth / ( / [inputscale floatvalue] ); double center = inputimage.extent.origin.x + inputwidth / 2.0; CGRect dod = dodforinputrect (inputimage.extent, center, k); } CIImage * result = [[self mykernel] applywithextent: dod roicallback: ^(int index, CGRect rect) { return regionof(rect, center, k); } inputimage: return result;

180 outputimage Method - (CIImage *) outputimage { double inputwidth = inputimage.extent.size.width; double k = inputwidth / ( / [inputscale floatvalue] ); double center = inputimage.extent.origin.x + inputwidth / 2.0; CGRect dod = dodforinputrect (inputimage.extent, center, k); } CIImage * result = [[self mykernel] applywithextent: dod roicallback: ^(int index, CGRect rect) { return regionof(rect, center, k); } inputimage: return result;

181 outputimage Method - (CIImage *) outputimage { double inputwidth = inputimage.extent.size.width; double k = inputwidth / ( / [inputscale floatvalue] ); double center = inputimage.extent.origin.x + inputwidth / 2.0; CGRect dod = dodforinputrect (inputimage.extent, center, k); } CIImage * result = [[self mykernel] applywithextent: dod roicallback: ^(int index, CGRect rect) { return regionof(rect, center, k); } inputimage: return result;

182 customattributes Method + (NSDictionary *)customattributes { kciattributefilterdisplayname Anamorphic Stretch", kciattributefiltercategories : kcicategoryvideo, kcicategoryinterlaced, kcicategorynonsquarepixels, kciattributeslidermin kciattributeslidermax kciattributedefault kciattributeidentity kciattributetype : kciattributetypescalar } };

183 customattributes Method + (NSDictionary *)customattributes { kciattributefilterdisplayname Anamorphic Stretch", kciattributefiltercategories : kcicategoryvideo, kcicategoryinterlaced, kcicategorynonsquarepixels, kciattributeslidermin kciattributeslidermax kciattributedefault kciattributeidentity kciattributetype : kciattributetypescalar } };

184 customattributes Method + (NSDictionary *)customattributes { kciattributefilterdisplayname Anamorphic Stretch", kciattributefiltercategories : kcicategoryvideo, kcicategoryinterlaced, kcicategorynonsquarepixels, kciattributeslidermin kciattributeslidermax kciattributedefault kciattributeidentity kciattributetype : kciattributetypescalar } };

185 customattributes Method + (NSDictionary *)customattributes { kciattributefilterdisplayname Anamorphic Stretch", kciattributefiltercategories : kcicategoryvideo, kcicategoryinterlaced, kcicategorynonsquarepixels, kciattributeslidermin kciattributeslidermax kciattributedefault kciattributeidentity kciattributetype : kciattributetypescalar } };

186 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

187 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

188 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

189 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

190 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

191 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

192 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

193 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

194 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

195 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

196 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

197 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

198 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

199 CIKernel Wrap-Up # Input Images Input Type Access Output Image DOD ROI ClColorKernel 0.. n sample vec4 vec4 YES NO ClWarpKernel 1 destcoord() vec2 vec2 YES YES ClKernel 0.. n sampler sample( ) vec4 YES YES

200 General Kernels CIKernel Tony Chu

201 Different Types of Kernels Color Kernels (CIColorKernel) Warp Kernels (CIWarpKernel) General Kernels (CIKernel)

202 Motivation CIKernel When would you need to write a general kernel?

203 Motivation CIKernel When would you need to write a general kernel? Kernel needs multiple samples of an image

204 Motivation CIKernel When would you need to write a general kernel? Kernel needs multiple samples of an image - e.g., any kind of blur or convolution filter

205 Motivation CIKernel When would you need to write a general kernel? Kernel needs multiple samples of an image - e.g., any kind of blur or convolution filter Kernel contains a dependent texture read

206 Motivation CIKernel When would you need to write a general kernel? Kernel needs multiple samples of an image - e.g., any kind of blur or convolution filter Kernel contains a dependent texture read - e.g., sample from image A used to determine where to sample from image B

207 Basic Principles of General Kernels CIKernel Input Input Image(s) Input Image(s) Output Image Sampler CIKernel CIImage

208 Basic Principles of General Kernels CIKernel Input Input Image(s) Input Image(s) Output Image Sampler CIKernel CIImage

209 Basic Principles of General Kernels kernel vec4 do_nothing (sampler image) { vec2 dc = destcoord(); return sample (image, samplertransform (image, dc)); }

210 Basic Principles of General Kernels kernel vec4 do_nothing (sampler image) { vec2 dc = destcoord(); return sample (image, samplertransform (image, dc)); } kernel vec4 do_nothing (sampler image) { return sample (image, samplercoord (image)); }

211 Basic Principles of General Kernels kernel vec4 do_nothing (sampler image) { vec2 dc = destcoord(); return sample (image, samplertransform (image, dc)); } = kernel vec4 do_nothing (sampler image) { return sample (image, samplercoord (image)); }

212 Basic Principles of General Kernels kernel vec4 do_nothing (sampler image) { vec2 dc = destcoord(); return sample (image, samplertransform (image, dc)); } = kernel vec4 do_nothing (sampler image) { return sample (image, samplercoord (image)); } Why use samplertransform?

213 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); }

214 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y Destination space x

215 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y y Destination space Sampler space x x

216 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y y Destination space Sampler space (300, 200) x x

217 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y y Destination space Sampler space (300, 200) (0.5, 0.5) x x

218 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y y (0.5, 2.5) Destination space Sampler space (300, 200) (0.5, 0.5) x x

219 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 sc = samplercoord (image); vec2 offset = vec2(0.0, 2.0); return sample (image, sc + offset); } y y (0.5, 2.5) Destination space Sampler space (300, 200) (0.5, 0.5) x x

220 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 dc = destcoord(); vec2 offset = vec2(0.0, 2.0); return sample (image, samplertransform (image, dc + offset)); } y y Destination space Sampler space x x

221 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 dc = destcoord(); vec2 offset = vec2(0.0, 2.0); return sample (image, samplertransform (image, dc + offset)); } y y Destination space Sampler space (300, 200) x x

222 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 dc = destcoord(); vec2 offset = vec2(0.0, 2.0); return sample (image, samplertransform (image, dc + offset)); } y y Destination space Sampler space 400 (300, 202) 1 (300, 200) x x

223 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 dc = destcoord(); vec2 offset = vec2(0.0, 2.0); return sample (image, samplertransform (image, dc + offset)); } y y Destination space Sampler space 400 (300, 202) 1 (300, 200) (0.5, 0.505) x x

224 Basic Principles of General Kernels Destination space vs. Sampler space kernel vec4 do_something (sampler image) { vec2 dc = destcoord(); vec2 offset = vec2(0.0, 2.0); return sample (image, samplertransform (image, dc + offset)); } y y Destination space Sampler space 400 (300, 202) 1 (300, 200) (0.5, 0.505) x x

225 Examples CIKernel

226 Motion Blur Kernel requires multiple samples

227 Motion Blur Kernel requires multiple samples Compute the average of N samples along a bi-directional vector

228 Motion Blur Kernel requires multiple samples Compute the average of N samples along a bi-directional vector

229 Motion Blur Kernel requires multiple samples Compute the average of N samples along a bi-directional vector

230 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

231 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

232 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

233 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

234 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

235 Motion Blur CIKernel kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } } return s / float((num_samples * 2 + 1));

236 Motion Blur CIFilter subclass - (CIKernel *)mykernel { static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ];

237 Motion Blur CIFilter subclass - (CIKernel *)mykernel { static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ];

238 Motion Blur CIFilter subclass - (CIKernel *)mykernel { kernel vec4 motionblur (sampler image, vec2 velocity) { const int NUM_SAMPLES = 10; // per direction vec4 s = vec4(0.0); vec2 dc = destcoord(), offset = -velocity; for (int i=0; i < (NUM_SAMPLES * 2 + 1); i++) { s += sample (image, samplertransform (image, dc + offset)); offset += velocity / float(num_samples); } return s / float((num_samples * 2 + 1)); } static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ]; }

239 Motion Blur CIFilter subclass - (CIKernel *)mykernel { static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ];

240 Motion Blur CIFilter subclass - (CIKernel *)mykernel { static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ];

241 Motion Blur CIFilter subclass - (CIKernel *)mykernel { static CIKernel *kernel = [CIKernel kernelwithstring:source]; return kernel; } - (CIImage *)outputimage { float r = inputradius.floatvalue, a = inputangle.floatvalue; CIVector *velocity = [CIVector vectorwithx:r*cos(a) Y:r*sin(a)]; } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof(rect,velocity); } velocity] ];

242 Motion Blur DOD extent.size.height extent.origin extent.size.width

243 Motion Blur DOD extent.size.height extent.origin extent.size.width

244 Motion Blur DOD extent.size.height extent.origin extent.size.width

245 Motion Blur DOD extent.size.height extent.origin extent.size.width

246 Motion Blur DOD extent.size.height extent.origin extent.size.width velocity.x

247 Motion Blur DOD extent.size.height extent.origin extent.size.width velocity.x DOD = CGRectInset (inputimage.extent, -abs(velocity.x), -abs(velocity.y));

248 Motion Blur ROI

249 Motion Blur ROI

250 Motion Blur ROI

251 Motion Blur ROI

252 Motion Blur ROI

253 Motion Blur ROI

254 Motion Blur ROI

255 Motion Blur ROI

256 Motion Blur ROI CGRect regionof (CGRect rect, CIVector *velocity) { return CGRectInset (rect, -abs(velocity.x), -abs(velocity.y)); }

257 Motion Blur 2.0

258 Motion Blur 2.0

259 Motion Blur 2.0

260 Motion Blur with Masked Vector Field Kernel contains dependent texture read

261 Motion Blur with Masked Vector Field Kernel contains dependent texture read

262 Motion Blur with Masked Vector Field Kernel contains dependent texture read

263 Motion Blur with Masked Vector Field Kernel contains dependent texture read CIKernel

264 Motion Blur with Masked Vector Field Kernel contains dependent texture read CIKernel

265 Motion Blur with Masked Vector Field Kernel contains dependent texture read CIKernel

266 Motion Blur with Masked Vector Field Kernel contains dependent texture read CIKernel

267 Motion Blur with Masked Vector Field CIKernel

268 Motion Blur with Masked Vector Field CIKernel

269 Motion Blur with Masked Vector Field CIKernel kernel vec4 motionblurwithmask (sampler image, sampler mask, float radius) { // read per-pixel directional vector from mask image first vec2 dir = sample (mask, samplercoord(mask)).rg; dir = dir * ; // de-normalize vector from [0,1] to [-1,+1] vec2 velocity = dir * radius; } return _motionblur (image, velocity);

270 Motion Blur with Masked Vector Field CIKernel vec4 _motionblur (sampler image, vec2 velocity) { } kernel vec4 motionblurwithmask (sampler image, sampler mask, float radius) { // read per-pixel directional vector from mask image first vec2 dir = sample (mask, samplercoord(mask)).rg; dir = dir * ; // de-normalize vector from [0,1] to [-1,+1] // apply regular motion blur effect vec2 velocity = dir * radius; } return _motionblur (image, velocity);

271 Motion Blur with Masked Vector Field CIKernel vec4 _motionblur (sampler image, vec2 velocity) { } kernel vec4 motionblurwithmask (sampler image, sampler mask, float radius) { // read per-pixel directional vector from mask image first vec2 dir = sample (mask, samplercoord(mask)).rg; dir = dir * ; // de-normalize vector from [0,1] to [-1,+1] // apply regular motion blur effect vec2 velocity = dir * radius; } return _motionblur (image, velocity);

272 Motion Blur with Masked Vector Field CIKernel vec4 _motionblur (sampler image, vec2 velocity) { } kernel vec4 motionblurwithmask (sampler image, sampler mask, float radius) { // read per-pixel directional vector from mask image first vec2 dir = sample (mask, samplercoord(mask)).rg; dir = dir * ; // de-normalize vector from [0,1] to [-1,+1] // apply regular motion blur effect vec2 velocity = dir * radius; } return _motionblur (image, velocity);

273 Motion Blur with Masked Vector Field CIKernel vec4 _motionblur (sampler image, vec2 velocity) { } kernel vec4 motionblurwithmask (sampler image, sampler mask, float radius) { // read per-pixel directional vector from mask image first vec2 dir = sample (mask, samplercoord(mask)).rg; dir = dir * ; // de-normalize vector from [0,1] to [-1,+1] // apply regular motion blur effect vec2 velocity = dir * radius; } return _motionblur (image, velocity);

274 Motion Blur with Masked Vector Field CIFilter subclass - (CIImage *)outputimage { float r = inputradius.floatvalue; CGRect DOD = CGRectInset (inputimage.extent, -r, -r); } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof (index, rect, r); } maskimage, inputradius] ];

275 Motion Blur with Masked Vector Field CIFilter subclass - (CIImage *)outputimage { float r = inputradius.floatvalue; CGRect DOD = CGRectInset (inputimage.extent, -r, -r); } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof (index, rect, r); } maskimage, inputradius] ];

276 Motion Blur with Masked Vector Field CIFilter subclass - (CIImage *)outputimage { float r = inputradius.floatvalue; CGRect DOD = CGRectInset (inputimage.extent, -r, -r); } return [[self mykernel] applywithextent:dod roicallback:^(int index, CGRect rect) { return regionof (index, rect, r); } maskimage, inputradius] ];

277 Motion Blur with Masked Vector Field ROI for multiple images CGRect regionof (int index, CGRect rect, float radius) { if (index == 0) { return CGRectInset (rect, -radius, -radius); // ROI for input image } else if (index == 1) { return rect; // ROI for mask image } } return CGRectNull; // should not reach here

278 Motion Blur with Masked Vector Field ROI for multiple images CGRect regionof (int index, CGRect rect, float radius) { if (index == 0) { return CGRectInset (rect, -radius, -radius); // ROI for input image } else if (index == 1) { return rect; // ROI for mask image } } return CGRectNull; // should not reach here

279 Motion Blur with Masked Vector Field ROI for multiple images CGRect regionof (int index, CGRect rect, float radius) { if (index == 0) { return CGRectInset (rect, -radius, -radius); // ROI for input image } else if (index == 1) { return rect; // ROI for mask image } } return CGRectNull; // should not reach here

280 Portability of General Kernels OS X and ios Desktop-class kernel type with the same language syntax and semantics as OS X

281 Portability of General Kernels OS X and ios Desktop-class kernel type with the same language syntax and semantics as OS X New built-in filters on ios ported from OS X using general kernels

282 Portability of General Kernels OS X and ios Desktop-class kernel type with the same language syntax and semantics as OS X New built-in filters on ios ported from OS X using general kernels Glass Distortion

283 Portability of General Kernels OS X and ios Desktop-class kernel type with the same language syntax and semantics as OS X New built-in filters on ios ported from OS X using general kernels Glass Distortion Histogram Display

284 Performance Considerations Multiple render passes Input Input Image(s) Input Image(s) Output Image Sampler CIKernel CIImage

285 Performance Considerations Multiple render passes Input Input Image(s) Input Image(s) Output Image Sampler CIKernel CIImage

286 Performance Considerations Multiple render passes Input Input Image(s) Input Image(s) Output Image Sampler CIKernel CIImage Each input image to a CIKernel adds an extra render pass

287 Intermediate Buffers kcicontextworkingformat 8-bit kciformatrgba8 16-bit kciformatrgbah Null Working Space (Color Management Off) Default Working Space (Linear Rec. 709) Needs Linear to srgb Needs 2X Memory

288 Intermediate Buffers kcicontextworkingformat 8-bit kciformatrgba8 16-bit kciformatrgbah Null Working Space (Color Management Off) Default Working Space (Linear Rec. 709) Needs Linear to srgb Needs 2X Memory

289 Intermediate Buffers kcicontextworkingformat 8-bit kciformatrgba8 16-bit kciformatrgbah Null Working Space (Color Management Off) Default Working Space (Linear Rec. 709) Needs Linear to srgb Needs 2X Memory

290 Intermediate Buffers kcicontextworkingformat 8-bit kciformatrgba8 16-bit kciformatrgbah Null Working Space (Color Management Off) Default Working Space (Linear Rec. 709) Needs Linear to srgb Needs 2X Memory

291 Square Kaleidoscope CIKernel?

292 Square Kaleidoscope CIKernel?

293 Square Kaleidoscope CIKernel? CIFilter? = CIKernel

294 Square Kaleidoscope CIKernel? CIFilter? = CIKernel

295 Square Kaleidoscope Better solution CIFilter? =

296 Square Kaleidoscope Better solution CIFilter? =

297 Square Kaleidoscope Better solution CIFilter CIWarpKernel? =

298 Square Kaleidoscope Better solution CIFilter CIWarpKernel? =

299 Square Kaleidoscope Better solution CIFilter CIWarpKernel? = + CIColorKernel

300 Square Kaleidoscope Better solution CIFilter CIWarpKernel? = + CIColorKernel

301 Square Kaleidoscope CIWarpKernel kernel vec2 squarekaleidoscopewarp (vec2 center, float size) { // offset by center and transform to unit square vec2 p = (destcoord() - center) / size; // calculate number of mirror reflections to get to this point float z = abs(floor(p.x)) + abs(floor(p.y)); // reflect this point into unit square space p = abs(mod(p, 2.0) - 1.0); } // transform back to destination space return (p * size) + center;

302 Square Kaleidoscope CIColorKernel kernel vec4 squarekaleidoscopecolor ( sample s, vec2 center, float size) { // offset by center and transform to unit square vec2 p = (destcoord() - center) / size; // calculate number of mirror reflections to get to this point float z = abs(floor(p.x)) + abs(floor(p.y)); // exponential decay float k = pow(0.8, z); } // multiply color sample with decay return vec4(s.rgb * k, s.a);

303 Square Kaleidoscope CIWarpKernel and CIColorKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ];

304 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ];

305 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ];

306 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ];

307 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ];

308 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ]; CIImage *outputimage = [colorkernel applywithextent:warpedimage.extent center, size] ];

309 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIColorKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ]; CIImage *outputimage = [colorkernel applywithextent:warpedimage.extent center, size] ];

310 Square Kaleidoscope CIWarpKernel and CIColorKernel CIWarpKernel CIColorKernel CIImage *warpedimage = [warpkernel applywithextent:cgrectinfinite roicallback:^(int index, CGRect rect) { return corerect; } inputimage:inputimage size] ]; CIImage *outputimage = [colorkernel applywithextent:warpedimage.extent center, size] ];

311 Recommendations

312 Recommendations Write a general kernel only when needed

313 Recommendations Write a general kernel only when needed Write a general kernel initially for rapid prototyping, then try replacing with some combination of warp and color kernels

314 Platform Differences

315 Platform Differences ios OS X Renderers GPU CPU and GPU Control flow in language Yes No Kernel classes CIKernel CIColorKernel CIWarpKernel CIKernel CISampler No Yes DOD CGRect CIFilterShape ROI Block Pointer Selector [CIFilter setdefaults] Automatic Explicit [CIFilter customattributes] Class Method Instance Method

316 What You ve Learned Today

317 What You ve Learned Today How to write Color, Warp, and general kernels

318 What You ve Learned Today How to write Color, Warp, and general kernels DOD and ROI

319 What You ve Learned Today How to write Color, Warp, and general kernels DOD and ROI ROI function is critical for large image support to work correctly and optimally

320 What You ve Learned Today How to write Color, Warp, and general kernels DOD and ROI ROI function is critical for large image support to work correctly and optimally Platform differences

321 More Information Allan Schaffer Graphics and Game Technologies Evangelist Developer Technical Support Apple Developer Forums

322 Related Sessions Introducing the Photos Frameworks Nob Hill Thursday 10:15AM Advances in Core Image Pacific Heights Thursday 2:00PM

323 Labs Core Image Lab Media Lab B Thursday 4:30PM

324

What s New in Core Image

What s New in Core Image Media #WWDC15 What s New in Core Image Session 510 David Hayward Engineering Manager Tony Chu Engineer Alexandre Naaman Lead Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display

More information

Image Processing and Effects with Core Image. David Hayward

Image Processing and Effects with Core Image. David Hayward Image Processing and Effects with Core Image David Hayward 2 What We Will Discuss Today A quick introduction to Core Image Getting started with Core Image Using Core Image efficiently Writing CIFilters

More information

Leveraging Touch Input on ios

Leveraging Touch Input on ios App Frameworks #WWDC16 Leveraging Touch Input on ios And getting the most out of Apple Pencil Session 220 Dominik Wagner UIKit Engineer 2016 Apple Inc. All rights reserved. Redistribution or public display

More information

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES UIKit OpenGL ES Core Graphics Core Animation

More information

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee

Custom Drawing & Animation. CS 442: Mobile App Development Michael Saelee Custom Drawing & Animation CS 442: Mobile App Development Michael Saelee 1 Frameworks - UIKit - Core Graphics / Quartz - Core Animation - OpenGL ES 2 UIKit OpenGL ES Core Graphics Core Animation

More information

Monday, 1 November The ios System

Monday, 1 November The ios System The ios System System Overview System Overview System Overview System Overview System Overview System Overview Foundation Classes (Useful) Foundation Framework Value and collection classes User defaults

More information

Views, Drawing, and Events. Lecture 5

Views, Drawing, and Events. Lecture 5 Views, Drawing, and Events Lecture 5 First - Representing Points and Areas NSPoint // Represents a point in a Cartesian coordinate system. typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair

More information

Introducing Metal 2. Graphics and Games #WWDC17. Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer

Introducing Metal 2. Graphics and Games #WWDC17. Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer Session Graphics and Games #WWDC17 Introducing Metal 2 601 Michal Valient, GPU Software Engineer Richard Schreyer, GPU Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public display

More information

Getting the Most out of Playgrounds in Xcode

Getting the Most out of Playgrounds in Xcode #WWDC18 Getting the Most out of Playgrounds in Xcode Session 402 Tibet Rooney-Rabdau, Xcode Engineer Alex Brown, Core OS Engineer TJ Usiyan, Xcode Engineer 2018 Apple Inc. All rights reserved. Redistribution

More information

Working With Metal Advanced

Working With Metal Advanced Graphics and Games #WWDC14 Working With Metal Advanced Session 605 Gokhan Avkarogullari GPU Software Aaftab Munshi GPU Software Serhat Tekin GPU Software 2014 Apple Inc. All rights reserved. Redistribution

More information

What's New in UIKit Dynamics and Visual Effects Session 229

What's New in UIKit Dynamics and Visual Effects Session 229 App Frameworks #WWDC15 What's New in UIKit Dynamics and Visual Effects Session 229 Michael Turner UIKit Engineer David Duncan UIKit Engineer 2015 Apple Inc. All rights reserved. Redistribution or public

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C

More information

Working with Metal Overview

Working with Metal Overview Graphics and Games #WWDC14 Working with Metal Overview Session 603 Jeremy Sandmel GPU Software 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

What s New in SpriteKit

What s New in SpriteKit Graphics and Games #WWDC14 What s New in SpriteKit Session 606 Norman Wang Game Technologies 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

Using Accelerate and simd

Using Accelerate and simd Session #WWDC18 Using Accelerate and simd 701 Matthew Badin, CoreOS, Vector and Numerics Luke Chang, CoreOS, Vector and Numerics 2018 Apple Inc. All rights reserved. Redistribution or public display not

More information

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011 Developing Applications for ios Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space Draws and handles events in that rectangle Hierarchical A view has only one

More information

Improving your Existing Apps with Swift

Improving your Existing Apps with Swift Developer Tools #WWDC15 Improving your Existing Apps with Swift Getting Swifty with It Session 403 Woody L. in the Sea of Swift 2015 Apple Inc. All rights reserved. Redistribution or public display not

More information

Profiling in Depth. Do you know where your code is? Session 412. Kris Markel Performance Tools Engineer Chad Woolf Performance Tools Engineer

Profiling in Depth. Do you know where your code is? Session 412. Kris Markel Performance Tools Engineer Chad Woolf Performance Tools Engineer Developer Tools #WWDC15 Profiling in Depth Do you know where your code is? Session 412 Kris Markel Performance Tools Engineer Chad Woolf Performance Tools Engineer 2015 Apple Inc. All rights reserved.

More information

Accessibility on OS X

Accessibility on OS X Frameworks #WWDC14 Accessibility on OS X New Accessibility API Session 207 Patti Hoa Accessibility Engineer! Chris Dolan Accessibility Engineer 2014 Apple Inc. All rights reserved. Redistribution or public

More information

Metal Shading Language for Core Image Kernels

Metal Shading Language for Core Image Kernels Metal Shading Language for Core Image Kernels apple Developer Contents Overview 3 CIKernel Function Requirements 4 Data Types 5 Destination Types.............................................. 5 Sampler

More information

Introducing the Photos Frameworks

Introducing the Photos Frameworks Media #WWDC14 Introducing the Photos Frameworks Session 511 Adam Swift ios Photos Frameworks 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

Building Visually Rich User Experiences

Building Visually Rich User Experiences Session App Frameworks #WWDC17 Building Visually Rich User Experiences 235 Noah Witherspoon, Software Engineer Warren Moore, Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

Metal for OpenGL Developers

Metal for OpenGL Developers #WWDC18 Metal for OpenGL Developers Dan Omachi, Metal Ecosystem Engineer Sukanya Sudugu, GPU Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without

More information

Using and Extending the Xcode Source Editor

Using and Extending the Xcode Source Editor Developer Tools #WWDC16 Using and Extending the Xcode Source Editor Session 414 Mike Swingler Xcode Infrastructure and Editors Chris Hanson Xcode Infrastructure and Editors 2016 Apple Inc. All rights reserved.

More information

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Core Graphics and OpenGL ES. Dr. Sarah Abraham Core Graphics and OpenGL ES Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 Core Graphics Apple s vector-drawing framework Previously known as Quartz or Quartz2D Includes handling for:

More information

The Projection Matrix

The Projection Matrix The Projection Matrix Lecture 8 Robb T. Koether Hampden-Sydney College Fri, Sep 11, 2015 Robb T. Koether (Hampden-Sydney College) The Projection Matrix Fri, Sep 11, 2015 1 / 43 Outline 1 Coordinate Systems

More information

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Custom Views and Drawing. Lecture 5

Custom Views and Drawing. Lecture 5 Custom Views and Drawing Lecture 5 First - Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint Pair of x, y coordinates NSZeroPoint represents the origin Create

More information

Adopting Advanced Features of the New UI

Adopting Advanced Features of the New UI Frameworks #WWDC14 Adopting Advanced Features of the New UI Session 220 Chris Dreessen AppKit Software Engineer! Corbin Dunn AppKit Software Engineer 2014 Apple Inc. All rights reserved. Redistribution

More information

Building Better Apps with Value Types in Swift Session 414

Building Better Apps with Value Types in Swift Session 414 Developer Tools #WWDC15 Building Better Apps with Value Types in Swift Session 414 Doug Gregor Language Lawyer Bill Dudney Arranger of Bits 2015 Apple Inc. All rights reserved. Redistribution or public

More information

What s New in Metal. Part 2 #WWDC16. Graphics and Games. Session 605

What s New in Metal. Part 2 #WWDC16. Graphics and Games. Session 605 Graphics and Games #WWDC16 What s New in Metal Part 2 Session 605 Charles Brissart GPU Software Engineer Dan Omachi GPU Software Engineer Anna Tikhonova GPU Software Engineer 2016 Apple Inc. All rights

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling

More information

Graphics & Animation: 2D Drawing

Graphics & Animation: 2D Drawing Core Graphics Framework Reference Graphics & Animation: 2D Drawing 2009-05-14 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,

More information

Custom Views and Events. Lecture 7

Custom Views and Events. Lecture 7 Custom Views and Events Lecture 7 First Representing Points and Areas NSPoint typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint; Pair of x, y coordinates NSZeroPoint represents the bottom left

More information

WebGL. Creating Interactive Content with WebGL. Media #WWDC14. Session 509 Dean Jackson and Brady Eidson WebKit Engineers

WebGL. Creating Interactive Content with WebGL. Media #WWDC14. Session 509 Dean Jackson and Brady Eidson WebKit Engineers Media #WWDC14 WebGL Creating Interactive Content with WebGL Session 509 Dean Jackson and Brady Eidson WebKit Engineers 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted

More information

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017 Abbott, Connor (cwa2112) Pan, Wendy (wp2213) Qinami, Klint (kq2129) Vaccaro, Jason (jhv2111) [System

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Timer Periodically execute a block of code Blinking FaceIt Demo Animation Animating changes to UIViews Smoother Blinking FaceIt Head-shaking FaceIt Animating

More information

Background Type Classes (1B) Young Won Lim 6/28/18

Background Type Classes (1B) Young Won Lim 6/28/18 Background Type Classes (1B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015

CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015 CMSC 150 Lab 8, Part II: Little PhotoShop of Horrors, Part Deux 10 Nov 2015 By now you should have completed the Open/Save/Quit portion of the menu options. Today we are going to finish implementing the

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

View Controller Advancements for ios8

View Controller Advancements for ios8 Frameworks #WWDC14 View Controller Advancements for ios8 Session 214 Bruce D. Nilo Manager, UIKit Fundamentals 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without

More information

t=t + "g"; On the other hand, arrays are mutable. The assignment a[i]=e/// where e element is equal 6

t=t + g; On the other hand, arrays are mutable. The assignment a[i]=e/// where e element is equal 6 Object Oriented Concepts 1.1. Mutability All objects either are immutable or mutable. the state of an immutable object never changes, while the state of a mutable object can change. String object are mutable,

More information

Metal Feature Set Tables

Metal Feature Set Tables Metal Feature Set Tables apple Developer Feature Availability This table lists the availability of major Metal features. OS ios 8 ios 8 ios 9 ios 9 ios 9 ios 10 ios 10 ios 10 ios 11 ios 11 ios 11 ios 11

More information

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012

Copyright Khronos Group 2012 Page 1. Teaching GL. Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 1 Teaching GL Dave Shreiner Director, Graphics and GPU Computing, ARM 1 December 2012 Copyright Khronos Group 2012 Page 2 Agenda Overview of OpenGL family of APIs Comparison

More information

CS193p Spring 2010 Thursday, April 29, 2010

CS193p Spring 2010 Thursday, April 29, 2010 CS193p Spring 2010 Announcements You should have received an e-mail by now If you received e-mail approving enrollment, but are not in Axess, do it! If you have any questions, please ask via e-mail or

More information

What s New in imessage Apps

What s New in imessage Apps Session App Frameworks #WWDC17 What s New in imessage Apps 234 Eugene Bistolas, Messages Engineer Jay Chae, Messages Engineer Stephen Lottermoser, Messages Engineer 2017 Apple Inc. All rights reserved.

More information

OpenGL Status - November 2013 G-Truc Creation

OpenGL Status - November 2013 G-Truc Creation OpenGL Status - November 2013 G-Truc Creation Vendor NVIDIA AMD Intel Windows Apple Release date 02/10/2013 08/11/2013 30/08/2013 22/10/2013 Drivers version 331.10 beta 13.11 beta 9.2 10.18.10.3325 MacOS

More information

Dave Shreiner, ARM March 2009

Dave Shreiner, ARM March 2009 4 th Annual Dave Shreiner, ARM March 2009 Copyright Khronos Group, 2009 - Page 1 Motivation - What s OpenGL ES, and what can it do for me? Overview - Lingo decoder - Overview of the OpenGL ES Pipeline

More information

GLSL Applications: 2 of 2

GLSL Applications: 2 of 2 Administrivia GLSL Applications: 2 of 2 Patrick Cozzi University of Pennsylvania CIS 565 - Spring 2011 Assignment 2 due today 11:59pm on Blackboard Assignment 3 handed out today Due Wednesday, 02/09 at

More information

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines EECS 556 Image Processing W 09 Interpolation Interpolation techniques B splines What is image processing? Image processing is the application of 2D signal processing methods to images Image representation

More information

The Application Stage. The Game Loop, Resource Management and Renderer Design

The Application Stage. The Game Loop, Resource Management and Renderer Design 1 The Application Stage The Game Loop, Resource Management and Renderer Design Application Stage Responsibilities 2 Set up the rendering pipeline Resource Management 3D meshes Textures etc. Prepare data

More information

What s New in tvos 12

What s New in tvos 12 #WWDC18 What s New in tvos 12 Session 208 Hans Kim, tvos Engineering 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Agenda Agenda

More information

Creating Photo and Video Effects Using Depth

Creating Photo and Video Effects Using Depth Session #WWDC18 Creating Photo and Video Effects Using Depth 503 Emmanuel Piuze-Phaneuf, Core Image Ron Sokolovsky, Video Engineering 2018 Apple Inc. All rights reserved. Redistribution or public display

More information

As you convert your QuickDraw application to one that uses only Quartz, there are two primary issues you ll face with respect to PICT data:

As you convert your QuickDraw application to one that uses only Quartz, there are two primary issues you ll face with respect to PICT data: C H A P T E R 4 Converting PICT Data The QuickDraw picture (PICT) format is the graphics metafile format in Mac OS 9 and earlier. A picture contains a recorded sequence of QuickDraw imaging operations

More information

CS 543: Computer Graphics. Rasterization

CS 543: Computer Graphics. Rasterization CS 543: Computer Graphics Rasterization Robert W. Lindeman Associate Professor Interactive Media & Game Development Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu (with lots

More information

Overview. By end of the week:

Overview. By end of the week: Overview By end of the week: - Know the basics of git - Make sure we can all compile and run a C++/ OpenGL program - Understand the OpenGL rendering pipeline - Understand how matrices are used for geometric

More information

Image Processing. Overview. Trade spatial resolution for intensity resolution Reduce visual artifacts due to quantization. Sampling and Reconstruction

Image Processing. Overview. Trade spatial resolution for intensity resolution Reduce visual artifacts due to quantization. Sampling and Reconstruction Image Processing Overview Image Representation What is an image? Halftoning and Dithering Trade spatial resolution for intensity resolution Reduce visual artifacts due to quantization Sampling and Reconstruction

More information

What s New in Metal, Part 2

What s New in Metal, Part 2 Graphics and Games #WWDC15 What s New in Metal, Part 2 Session 607 Dan Omachi GPU Software Frameworks Engineer Anna Tikhonova GPU Software Frameworks Engineer 2015 Apple Inc. All rights reserved. Redistribution

More information

Enhancing your apps for the next dimension of touch

Enhancing your apps for the next dimension of touch App Frameworks #WWDC16 A Peek at 3D Touch Enhancing your apps for the next dimension of touch Session 228 Tyler Fox UIKit Frameworks Engineer Peter Hajas UIKit Frameworks Engineer 2016 Apple Inc. All rights

More information

DH2323 DGI13. Lab 2 Raytracing

DH2323 DGI13. Lab 2 Raytracing DH2323 DGI13 Lab 2 Raytracing In this lab you will implement a Raytracer, which draws images of 3D scenes by tracing the light rays reaching the simulated camera. The lab is divided into several steps.

More information

Introduction to Shaders.

Introduction to Shaders. Introduction to Shaders Marco Benvegnù hiforce@gmx.it www.benve.org Summer 2005 Overview Rendering pipeline Shaders concepts Shading Languages Shading Tools Effects showcase Setup of a Shader in OpenGL

More information

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines Emmanuel Agu 2D Graphics Pipeline Clipping Object World Coordinates Applying world window Object subset window to viewport mapping

More information

OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction

OUTLINE. Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction TEXTURE MAPPING 1 OUTLINE Implementing Texturing What Can Go Wrong and How to Fix It Mipmapping Filtering Perspective Correction 2 BASIC STRAGEGY Three steps to applying a texture 1. specify the texture

More information

Ruby: Objects and Dynamic Types

Ruby: Objects and Dynamic Types Ruby: Objects and Dynamic Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 5 Primitive vs Reference Types Recall Java type dichotomy: Primitive: int, float,

More information

MORE ARRAYS: THE GAME OF LIFE CITS1001

MORE ARRAYS: THE GAME OF LIFE CITS1001 MORE ARRAYS: THE GAME OF LIFE CITS1001 2 Scope of this lecture The Game of Life Implementation Performance Issues References: http://www.bitstorm.org/gameoflife/ (and hundreds of other websites) 3 Game

More information

OpenGL BOF Siggraph 2011

OpenGL BOF Siggraph 2011 OpenGL BOF Siggraph 2011 OpenGL BOF Agenda OpenGL 4 update Barthold Lichtenbelt, NVIDIA OpenGL Shading Language Hints/Kinks Bill Licea-Kane, AMD Ecosystem update Jon Leech, Khronos Viewperf 12, a new beginning

More information

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C? Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:

More information

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 Grand Central Dispatch and NSOperation CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 1 Credit Where Credit Is Due Most of the examples in this lecture were inspired by example code

More information

Metal for Ray Tracing Acceleration

Metal for Ray Tracing Acceleration Session #WWDC18 Metal for Ray Tracing Acceleration 606 Sean James, GPU Software Engineer Wayne Lister, GPU Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted

More information

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer

ios Memory Deep Dive #WWDC18 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer Session #WWDC18 ios Memory Deep Dive 416 Kyle Howarth, Software Engineer James Snee, Software Engineer Kris Markel, Software Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display

More information

Lecture 13: OpenGL Shading Language (GLSL)

Lecture 13: OpenGL Shading Language (GLSL) Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 18, 2018 1/56 Motivation } Last week, we discussed the many of the new tricks in Graphics require low-level access to the Graphics

More information

PYTHON. Values and Variables

PYTHON. Values and Variables December 13 2017 Naveen Sagayaselvaraj PYTHON Values and Variables Overview Integer Values Variables and Assignment Identifiers Floating-point Types User Input The eval Function Controlling the print Function

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 12 Introduction to ObjectiveC 2013/2014 Parma Università degli Studi di Parma Lecture Summary ObjectiveC language basics Classes and objects Methods Instance variables

More information

Advanced Scrollviews and Touch Handling Techniques

Advanced Scrollviews and Touch Handling Techniques Frameworks #WWDC14 Advanced Scrollviews and Touch Handling Techniques Session 235 Josh Shaffer ios Apps and Frameworks Engineer Eliza Block ios Apps and Frameworks Engineer 2014 Apple Inc. All rights reserved.

More information

Texture Mapping 1/34

Texture Mapping 1/34 Texture Mapping 1/34 Texture Mapping Offsets the modeling assumption that the BRDF doesn t change in u and v coordinates along the object s surface Store a reflectance as an image called a texture Map

More information

Announcements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2

Announcements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2 Announcements Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017 Stanford Developing Applications for ios Today Error Handling in Swift try Extensions A simple, powerful, but easily overused code management syntax Protocols Last (but certainly not least important) typing

More information

Moving Mobile Graphics Advanced Real-time Shadowing. Marius Bjørge ARM

Moving Mobile Graphics Advanced Real-time Shadowing. Marius Bjørge ARM Moving Mobile Graphics Advanced Real-time Shadowing Marius Bjørge ARM Shadow algorithms Shadow filters Results Agenda SHADOW ALGORITHMS Shadow Algorithms Shadow mapping Depends on light type Directional,

More information

CS 4204 Computer Graphics

CS 4204 Computer Graphics CS 424 Computer Graphics 2D Transformations Yong Cao Virginia Tech References: Introduction to Computer Graphics course notes by Doug Bowman Interactive Computer Graphics, Fourth Edition, Ed Angle Transformations

More information

View Controller Lifecycle

View Controller Lifecycle View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain

More information

VGP352 Week March-2008

VGP352 Week March-2008 VGP352 Week 10 Agenda: Texture rectangles Post-processing effects Filter kernels Simple blur Edge detection Separable filter kernels Gaussian blur Depth-of-field Texture Rectangle Cousin to 2D textures

More information

GPGPU: Parallel Reduction and Scan

GPGPU: Parallel Reduction and Scan Administrivia GPGPU: Parallel Reduction and Patrick Cozzi University of Pennsylvania CIS 565 - Spring 2011 Assignment 3 due Wednesday 11:59pm on Blackboard Assignment 4 handed out Monday, 02/14 Final Wednesday

More information

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science Texture Mapping CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science 1 Objectives Introduce Mapping Methods - Texture Mapping - Environment Mapping - Bump Mapping Consider

More information

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2

Loops. Variable Scope Remapping Nested Loops. Donald Judd. CS Loops 1. CS Loops 2 Loops Variable Scope Remapping Nested Loops CS105 05 Loops 1 Donald Judd CS105 05 Loops 2 judd while (expression) { statements CS105 05 Loops 3 Four Loop Questions 1. What do I want to repeat? - a rect

More information

Porting Objective-C to Swift. Richard Ekle

Porting Objective-C to Swift. Richard Ekle Porting Objective-C to Swift Richard Ekle rick@ekle.org Why do we need this? 1.2 million apps in the ios App Store http://www.statista.com/statistics/276623/numberof-apps-available-in-leading-app-stores/

More information

CS193E Lecture 12. Formatters Cocoa Text More View Drawing

CS193E Lecture 12. Formatters Cocoa Text More View Drawing CS193E Lecture 12 Formatters Cocoa Text More View Drawing Quick Scroll View Demo Announcements Questions on previous material or assignment? If you don t get a grade by Sunday, please let us know Some

More information

CUSTOM VIEWS. The View Hierarchy. Chapter 12

CUSTOM VIEWS. The View Hierarchy. Chapter 12 Chapter 12 CUSTOM VIEWS A ll the visible objects in an application are either windows or views. In this chapter, you will create a subclass of NSView. From time to time, you will create a custom view to

More information

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Buffers. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015 Buffers 1 Objectives Introduce additional WebGL buffers Reading and writing buffers Buffers and Images 2 Buffer Define a buffer by its spatial resolution (n x m) and its depth (or precision) k, the number

More information

What s New in LLDB. Debug your way to fame and glory #WWDC15. Developer Tools. Session 402

What s New in LLDB. Debug your way to fame and glory #WWDC15. Developer Tools. Session 402 Developer Tools #WWDC15 What s New in LLDB Debug your way to fame and glory Session 402 Kate Stone Software Behavioralist Sean Callanan Master of Expressions Enrico Granata Data Wizard 2015 Apple Inc.

More information

Today s Topics. Views Drawing Text & Images Animation

Today s Topics. Views Drawing Text & Images Animation Today s Topics Views Drawing Text & Images Animation 4 Views 5 View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically

More information

Compute Shaders. Christian Hafner. Institute of Computer Graphics and Algorithms Vienna University of Technology

Compute Shaders. Christian Hafner. Institute of Computer Graphics and Algorithms Vienna University of Technology Compute Shaders Christian Hafner Institute of Computer Graphics and Algorithms Vienna University of Technology Overview Introduction Thread Hierarchy Memory Resources Shared Memory & Synchronization Christian

More information

Arrays and Strings

Arrays and Strings Arrays and Strings 02-201 Arrays Recall: Fibonacci() and Arrays 1 1 2 3 5 8 13 21 34 55 a Fibonacci(n) a ß array of length n a[1] ß 1 a[2] ß 1 for i ß 3 to n a[i] ß a[i-1] + a[i-2] return a Declaring Arrays

More information

Modern User Interaction on ios

Modern User Interaction on ios App Frameworks #WWDC17 Modern User Interaction on ios Mastering the UIKit UIGesture System Session 219 Dominik Wagner, UIKit Engineer Michael Turner, UIKit Engineer Glen Low, UIKit Engineer 2017 Apple

More information

View Hierarchy - UIWindow

View Hierarchy - UIWindow Views and Drawing Views View Fundamentals Rectangular area on screen Draws content Handles events Subclass of UIResponder (event handling class) Views arranged hierarchically every view has one superview

More information

CS193E Lecture 14. Cocoa Bindings

CS193E Lecture 14. Cocoa Bindings CS193E Lecture 14 Cocoa Bindings Agenda Questions? Personal Timeline IV Key Value Coding Key Value Observing Key Value Binding Cocoa Bindings What are Cocoa Bindings? Added in Panther, more mature in Tiger

More information

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015 WebGL and GLSL Basics CS559 Fall 2015 Lecture 10 October 6, 2015 Last time Hardware Rasterization For each point: Compute barycentric coords Decide if in or out.7,.7, -.4 1.1, 0, -.1.9,.05,.05.33,.33,.33

More information

Vision Framework. Building on Core ML. Media #WWDC17. Brett Keating, Apple Manager Frank Doepke, He who wires things together

Vision Framework. Building on Core ML. Media #WWDC17. Brett Keating, Apple Manager Frank Doepke, He who wires things together Session Media #WWDC17 Vision Framework Building on Core ML 506 Brett Keating, Apple Manager Frank Doepke, He who wires things together 2017 Apple Inc. All rights reserved. Redistribution or public display

More information

Renderscript. Lecture May Android Native Development Kit. NDK Renderscript, Lecture 10 1/41

Renderscript. Lecture May Android Native Development Kit. NDK Renderscript, Lecture 10 1/41 Renderscript Lecture 10 Android Native Development Kit 6 May 2014 NDK Renderscript, Lecture 10 1/41 RenderScript RenderScript Compute Scripts RenderScript Runtime Layer Reflected Layer Memory Allocation

More information

Methods. Contents Anatomy of a Method How to design a Method Static methods Additional Reading. Anatomy of a Method

Methods. Contents Anatomy of a Method How to design a Method Static methods Additional Reading. Anatomy of a Method Methods Objectives: 1. create a method with arguments 2. create a method with return value 3. use method arguments 4. use the return keyword 5. use the static keyword 6. write and invoke static methods

More information