... | ... | @@ -422,11 +422,101 @@ Creating an image filter chain object with the property list dictionary defined |
|
|
|
|
|
smig create -type "imagefilterchain" -name "com.yvs.documentation.unsharpmaskfilterchain" -propertyfile "~/PLISTFilterFiles/unsharpmask.plist"
|
|
|
|
|
|
|
|
|
### The Image Filter Chain ruby processing scripts
|
|
|
|
|
|
There are three main scripts that come with Moving Images for processing images. The simplesinglecifilter script
|
|
|
The demonstration for using the image filter chain scripts assumes that the scripts are in folder that is in your PATH.
|
|
|
|
|
|
There are four scripts that come with Moving Images for applying core image filters to images. They are the coreimageblend, simplesinglecifilter, dotransition and embossimage. All these scripts take the command line switch --help which returns information about how to use the script.
|
|
|
|
|
|
coreimageblend --help
|
|
|
|
|
|
There is also the --verbose option, which is helpful when debugging writing scripts but can also be useful when you want to grab the generated json objects which is how I used the embossimage script when I needed json objects for this documentation.
|
|
|
|
|
|
The coreimageblend script takes two input images, combines them together using the selected Core Image blend filter and produces an output image:
|
|
|
|
|
|
To get a list of the core image blend filters:
|
|
|
|
|
|
coreimageblend --listfilters
|
|
|
|
|
|
Which returns:
|
|
|
|
|
|
CIAdditionCompositing CIColorBlendMode CIColorBurnBlendMode CIColorDodgeBlendMode CIDarkenBlendMode CIDifferenceBlendMode
|
|
|
CIExclusionBlendMode CIHardLightBlendMode CIHueBlendMode CILightenBlendMode CILuminosityBlendMode CIMaximumCompositing CIMinimumCompositing
|
|
|
CIMultiplyBlendMode CIMultiplyCompositing CIOverlayBlendMode CISaturationBlendMode CIScreenBlendMode CISoftLightBlendMode
|
|
|
CISourceAtopCompositing CISourceInCompositing CISourceOutCompositing CISourceOverCompositing
|
|
|
|
|
|
To combine two images using a core image blend filter:
|
|
|
|
|
|
coreimageblend --filter CISourceOverCompositing --foregroundimage "~/images/horizontaltestpattern.png" --backgroundimage "~/images/verticaltestpattern.png" --outputfile "~/Desktop/SourceOverTestPattern.png"
|
|
|
|
|
|
The simplesinglecifilter script allows you to apply a single core image filter to an image and save the result as a new image file. The simplesinglecifilter script only allows you to apply a filter which has relatively simple inputs. This means a filter that takes a single input image, and 2 or fewer numerical inputs. Filters that are not available are ones that takes inputs that are vectors or colors, or ones that take an image which is assigned as an input using a key other than "inputImage".
|
|
|
|
|
|
To get a list of filters that simplesinglecifilter can apply to an image:
|
|
|
|
|
|
simplesinglecifilter --listfilters
|
|
|
|
|
|
Which returns:
|
|
|
|
|
|
CIBloom CIBoxBlur CIColorInvert CIColorPosterize CIComicEffect CIDiscBlur CIEdges CIEdgeWork CIExposureAdjust CIGammaAdjust CIGaussianBlur
|
|
|
CIHeightFieldFromMask CIHueAdjust CIMaskToAlpha CIMaximumComponent CIMedianFilter CIMinimumComponent CINoiseReduction CIPhotoEffectChrome
|
|
|
CIPhotoEffectFade CIPhotoEffectInstant CIPhotoEffectMono CIPhotoEffectNoir CIPhotoEffectProcess CIPhotoEffectTonal CIPhotoEffectTransfer CISepiaTone
|
|
|
CISharpenLuminance CIStraightenFilter CIUnsharpMask
|
|
|
|
|
|
To get information about the inputs for a specific filter, for example the CIUnsharpMask:
|
|
|
|
|
|
simplesinglecifilter --filterproperties CIUnsharpMask
|
|
|
|
|
|
Which returns:
|
|
|
|
|
|
{
|
|
|
"cifiltername": "CIUnsharpMask",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputRadius",
|
|
|
"min": 0.0,
|
|
|
"max": 100.0,
|
|
|
"default": 2.5,
|
|
|
"cifiltervalue": 2.5
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputIntensity",
|
|
|
"min": 0.0,
|
|
|
"max": 2.0,
|
|
|
"default": 1.0,
|
|
|
"cifiltervalue": 1.0
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
The "cifilterproperties" key has an array of filter properties as its value. The order is important, the first item in the array relates to input 1, and the second is input 1. The min, max, and default keys are informational only, letting you what range of values is appropriate to assigning to the inputs for the filter.
|
|
|
|
|
|
To apply the unsharp mask filter to an image:
|
|
|
|
|
|
simplesinglecifilter --filter CIUnsharpMask --inputvalue1=4 --inputvalue2=1.3 --inputimage "~/Desktop/fuzzyimage.jpg" --outputfiletype public.jpeg --outputfile "~/Desktop/Unsharpedfuzzyimage.jpg"
|
|
|
|
|
|
The option "inputvalue1" relates to the "inputRadius" property of the CIUnsharpMask filter while "inputvalue2" relates to the "inputIntensity" of the CIUnsharpMask filter.
|
|
|
|
|
|
The "dotranstion" filter allows you to use any of the Core Image transition filters to transition from one image to another. This script is a bit more involved than the others with more command line options. Reading the output when using the "--help" command line option is sensible. The "dotransition" script will produce multiple images for each transition, you can specify how many images with the "--count" command line option.
|
|
|
|
|
|
To get the list of transition filters:
|
|
|
|
|
|
dotranstion --listtransitionfilters
|
|
|
|
|
|
Which returns:
|
|
|
|
|
|
CIBarsSwipeTransition CIRippleTransition CISwipeTransition CICopyMachineTransition CIDisintegrateWithMaskTransition CIFlashTransition
|
|
|
CIDissolveTransition CIModTransition CIPageCurlTransition CIPageCurlWithShadowTransition
|
|
|
|
|
|
One example of the use of the dotransition script is, though you'll need to update the file paths to image files on your computer:
|
|
|
|
|
|
dotransition --count 30 --sourceimage "~/Desktop/exampleimages/DSCN0744.JPG" --destinationimage "~/Desktop/exampleimages/DSCN0746.JPG" --transitionfilter CIFlashTransition --striationstrength 0.8 --color 1.0,0.4,0.1,1.0 --fadethreshold 0.7 --extent 0,0,908,681 --center 454,340 --striationcontrast 1.375 --outputdir "~/Desktop/junkimages/flashtransition" --basename Flash --outputfiletype public.jpeg --verbose
|
|
|
|
|
|
[Examples for using all the core image transition filters](../blob/master/coreimage/transitioncommands.sh)
|
|
|
|
|
|
The "embossimage" script is more a demonstration script than a general purpose script, and is the basis for how I have demonstrated many of the features of the image filter chain object and how to chain filters together as described the documentation. Nevertheless the script has a number of inputs making it possible to view how changing input values affects the produced output.
|
|
|
|
|
|
### The YVSChromaKey filter
|
|
|
|
|
|
As well as the built in Core Image filters I have added another filter for use with Moving Images. It is called YVSChromaKey and allows you to make parts of an image based on a selected color transparent. The filter has three inputs, a chroma key color "inputColor" which is defined as a CIVector, a distance number "inputDistance" which is distance in a color space within which the image is made fully transparent and a slope number "inputSlopeWidth" which is also a distance in a color space and this is the width of the slope. The smaller the width the steeper the slope.
|
|
|
|
|
|
[Home](Home) | [Contents](Contents) | [Previous - Drawing in a Bitmap Context](DrawingInABitmapContext) | [Next - Image Metadata](ImageMetadata) |