This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnrolledKuwaharaFilter: CIFilter | |
{ | |
var inputImage: CIImage? | |
var inputRadius: CGFloat = 15 | |
{ | |
didSet | |
{ | |
if Int(inputRadius) != Int(oldValue) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CIVector | |
{ | |
func multiply(value: CGFloat) -> CIVector | |
{ | |
let n = self.count | |
var targetArray = [CGFloat]() | |
for i in 0 ..< n | |
{ | |
targetArray.append(self.valueAtIndex(i) * value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension CIVector | |
{ | |
func normalize() -> CIVector | |
{ | |
var sum: CGFloat = 0 | |
for i in 0 ..< self.count | |
{ | |
sum += self.valueAtIndex(i) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void drawLine(texture2d<float, access::write> targetTexture, uint2 start, uint2 end); | |
void drawLine(texture2d<float, access::write> targetTexture, uint2 start, uint2 end) | |
{ | |
int x = int(start.x); | |
int y = int(start.y); | |
int dx = abs(x - int(end.x)); | |
int dy = abs(y - int(end.y)); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func imageOrientationToTiffOrientation(value: UIImageOrientation) -> Int32 | |
{ | |
switch (value) | |
{ | |
case UIImageOrientation.Up: | |
return 1 | |
case UIImageOrientation.Down: | |
return 3 | |
case UIImageOrientation.Left: | |
return 8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let monalisa = NSImage(named: "monalisa.jpg")! | |
let tiffData = monalisa.TIFFRepresentation! | |
let bitmap = NSBitmapImageRep(data: tiffData) | |
let image = CIImage(bitmapImageRep: bitmap!)! |
OlderNewer