当我尝试使用两个 CIFilter 时出现一些问题
我想要一张尽可能清晰的黑白图片,适用于 iPad 和 iPhone 的应用程序。
为此我做了很多事情:
1 - 我用 iPad 或 iPhone 的相机拍照。
2 - 我应用我的第一个过滤器 == CIColorMonochrome == 并显示以确定是否有效。 我的第一个过滤器效果很好。
3 - 我恢复了最后一个过滤器的结果,并用它来应用我的新过滤器== CINoiseReduction ==,然后我显示它以确保它是否也有效!但这次它什么也没显示,所以我不知道为什么。
//CIColorMonochrome
CIFilter * monochromeFilter;
monochromeFilter = [CIFilter filterWithName:@"CIColorMonochrome"];
[monochromeFilter setValue:beginImage forKey:@"inputImage"];
//Red Green Blue Alpha
[monochromeFilter setValue:[CIColor colorWithString:@"255 255 255 1.0"] forKey:@"inputColor"];
[monochromeFilter setValue:[NSNumber numberWithFloat:1] forKey:@"inputIntensity"];
CIImage* monochromeImage = [monochromeFilter valueForKey:@"outputImage"];
CIImage* outputImage = monochromeImage;
//---===---
CIFilter* noiseReductionFilter = [CIFilter filterWithName:@"CINoiseReduction"];
//[noiseReductionFilter setDefaults];
[noiseReductionFilter setValue:outputImage forKey:@"inputImage"];
[noiseReductionFilter setValue:[NSNumber numberWithFloat:0.2] forKey:@"inputNoiseLevel"];
[noiseReductionFilter setValue:[NSNumber numberWithFloat:0.40] forKey:@"inputSharpness"];
[noiseReductionFilter retain];
CIImage* noiseReductionImage = [noiseReductionFilter valueForKey:@"outputImage"];
// ---===---
outputImage = noiseReductionImage;
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[beginImage extent]];
UIImage* newImg = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
[imageView removeFromSuperview];
CGRect imageFrame = [imageView frame];
[imageView release];
// [self noiseReduction:newImg];
imageView = [[UIImageView alloc]initWithImage:newImg];
NSLog(@"%@ ===---=== " ,[self noiseReduction:newImg]);
if (flag == 0)
[imageView setFrame:imageFrame]; NSLog(@"setFrame image");
NSLog(@"%@ ==== ", imageView);
[[self view]addSubview:imageView];
亲切地
i want to have a picture black&white the most clear as possible, for an app iPad et iPhone.
i did many thing for that :
1 - i take my picture with iPad's or iPhone's camera.
2 - i apply my first filter == CIColorMonochrome == and i display to be sure if that work.
my first filter work well.
3 - i recover the result of my last filter and i use it to apply my new filter == CINoiseReduction == and i display it to be sure if that work too ! but this time it display nothing so i don't know why.
//CIColorMonochrome
CIFilter * monochromeFilter;
monochromeFilter = [CIFilter filterWithName:@"CIColorMonochrome"];
[monochromeFilter setValue:beginImage forKey:@"inputImage"];
//Red Green Blue Alpha
[monochromeFilter setValue:[CIColor colorWithString:@"255 255 255 1.0"] forKey:@"inputColor"];
[monochromeFilter setValue:[NSNumber numberWithFloat:1] forKey:@"inputIntensity"];
CIImage* monochromeImage = [monochromeFilter valueForKey:@"outputImage"];
CIImage* outputImage = monochromeImage;
//---===---
CIFilter* noiseReductionFilter = [CIFilter filterWithName:@"CINoiseReduction"];
//[noiseReductionFilter setDefaults];
[noiseReductionFilter setValue:outputImage forKey:@"inputImage"];
[noiseReductionFilter setValue:[NSNumber numberWithFloat:0.2] forKey:@"inputNoiseLevel"];
[noiseReductionFilter setValue:[NSNumber numberWithFloat:0.40] forKey:@"inputSharpness"];
[noiseReductionFilter retain];
CIImage* noiseReductionImage = [noiseReductionFilter valueForKey:@"outputImage"];
// ---===---
outputImage = noiseReductionImage;
CGImageRef cgimg = [context createCGImage:outputImage fromRect:[beginImage extent]];
UIImage* newImg = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
[imageView removeFromSuperview];
CGRect imageFrame = [imageView frame];
[imageView release];
// [self noiseReduction:newImg];
imageView = [[UIImageView alloc]initWithImage:newImg];
NSLog(@"%@ ===---=== " ,[self noiseReduction:newImg]);
if (flag == 0)
[imageView setFrame:imageFrame]; NSLog(@"setFrame image");
NSLog(@"%@ ==== ", imageView);
[[self view]addSubview:imageView];
cordially
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档显示“适用于 OS X v10.4 及更高版本”。 https://developer.apple.com/library/ios/documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/uid/TP40004346
Documentation says "Available in OS X v10.4 and later." https://developer.apple.com/library/ios/documentation/graphicsimaging/Reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/uid/TP40004346