Domanda

I am playing around with CI filters, but am having a spot of trouble with de-noising. Basically I get a blank image from this.

I am sure that I am just missing something simple.

Here's my code:

CGImageRef imageRef = [self.iv.image CGImage];
CIContext *context = [CIContext contextWithOptions:nil]; // 1
CIImage *ciImage = [CIImage imageWithCGImage:imageRef]; // 2
CIFilter *filter = [CIFilter filterWithName:@"CINoiseReduction" ];
[filter setDefaults];
[filter setValue:ciImage forKey:@"inputImage"]; // 3
CIImage *ciResult = [filter valueForKey:kCIOutputImageKey]; // 4
CGImageRef cgImage = [context createCGImage:ciResult fromRect:[ciResult extent]];
UIImage *img = [UIImage imageWithCGImage:cgImage];
self.iv.image = img;
È stato utile?

Soluzione

Aaaaaaand... it's because that filter is NOT available on iOS, and so the line:

CIFilter *filter = [CIFilter filterWithName:@"CINoiseReduction" ];

...returns null. Because, you know, that might be what you actually wanted :)

Here's the list of CI filters, along with notes on availability.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top