iOS 5 支持模糊 CoreImage 滤镜吗?
根据文档,它应该支持模糊,请注意“在 iOS 5.0 及更高版本中可用”:
但根据设备,它不:
[CIFilter filterNamesInCategory:kCICategoryBlur];
不返回任何内容。
根据以下内容,只有这些过滤器在我的 iPhone 和模拟器(都运行 5.0)上可用:
[CIFilter filterNamesInCategory:kCICategoryBuiltIn]
CIAdditionCompositing,
CIAffineTransform,
CICheckerboardGenerator,
CIColorBlendMode,
CIColorBurnBlendMode,
CIColorControls,
CIColorCube,
CIColorDodgeBlendMode,
CIColorInvert,
CIColorMatrix,
CIColorMonochrome,
CIConstantColorGenerator,
CICrop,
CIDarkenBlendMode,
CIDifferenceBlendMode,
CIExclusionBlendMode,
CIExposureAdjust,
CIFalseColor,
CIGammaAdjust,
CIGaussianGradient,
CIHardLightBlendMode,
CIHighlightShadowAdjust,
CIHueAdjust,
CIHueBlendMode,
CILightenBlendMode,
CILinearGradient,
CILuminosityBlendMode,
CIMaximumCompositing,
CIMinimumCompositing,
CIMultiplyBlendMode,
CIMultiplyCompositing,
CIOverlayBlendMode,
CIRadialGradient,
CISaturationBlendMode,
CIScreenBlendMode,
CISepiaTone,
CISoftLightBlendMode,
CISourceAtopCompositing,
CISourceInCompositing,
CISourceOutCompositing,
CISourceOverCompositing,
CIStraightenFilter,
CIStripesGenerator,
CITemperatureAndTint,
CIToneCurve,
CIVibrance,
CIVignette,
CIWhitePointAdjust
According to the documentation it should support blurring, note the "Available in iOS 5.0 and later":
But according to the device, it doesn't:
[CIFilter filterNamesInCategory:kCICategoryBlur];
returns nothing.
According to the following only these filters are available on my iPhone and Simulator (which are both running 5.0):
[CIFilter filterNamesInCategory:kCICategoryBuiltIn]
CIAdditionCompositing,
CIAffineTransform,
CICheckerboardGenerator,
CIColorBlendMode,
CIColorBurnBlendMode,
CIColorControls,
CIColorCube,
CIColorDodgeBlendMode,
CIColorInvert,
CIColorMatrix,
CIColorMonochrome,
CIConstantColorGenerator,
CICrop,
CIDarkenBlendMode,
CIDifferenceBlendMode,
CIExclusionBlendMode,
CIExposureAdjust,
CIFalseColor,
CIGammaAdjust,
CIGaussianGradient,
CIHardLightBlendMode,
CIHighlightShadowAdjust,
CIHueAdjust,
CIHueBlendMode,
CILightenBlendMode,
CILinearGradient,
CILuminosityBlendMode,
CIMaximumCompositing,
CIMinimumCompositing,
CIMultiplyBlendMode,
CIMultiplyCompositing,
CIOverlayBlendMode,
CIRadialGradient,
CISaturationBlendMode,
CIScreenBlendMode,
CISepiaTone,
CISoftLightBlendMode,
CISourceAtopCompositing,
CISourceInCompositing,
CISourceOutCompositing,
CISourceOverCompositing,
CIStraightenFilter,
CIStripesGenerator,
CITemperatureAndTint,
CIToneCurve,
CIVibrance,
CIVignette,
CIWhitePointAdjust
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
虽然 iOS 5.0 上的 Core Image 缺少模糊滤镜,但仍有一种方法可以实现 GPU 加速的图像和视频模糊。我的开源 GPUImage 框架有多种模糊类型,包括高斯(使用 GPUImageGaussianBlurFilter 进行一般高斯或用于硬件优化的 9 命中高斯的 GPUImageFastBlurFilter)、框(使用 GPUImageBoxBlurFilter)、中值(使用GPUImageMedianFilter)和双边模糊(使用 GPUImageBilingualBlurFilter)。
我在这个答案中描述了用于实现硬件优化高斯模糊的着色器,您可以检查我使用的代码框架内的其余部分。这些过滤器的运行速度比我尝试过的任何受 CPU 限制的例程快数十倍。
我还将这些模糊合并到多级处理效果中,例如锐化掩蔽、倾斜移位过滤、Canny 边缘检测和 Harris 角点检测,所有这些都可以用作此框架中的过滤器。
While Core Image on iOS 5.0 lacks blur filters, there is still a way to get GPU-accelerated blurs of images and video. My open source GPUImage framework has multiple blur types, including Gaussian (using the GPUImageGaussianBlurFilter for a general Gaussian or the GPUImageFastBlurFilter for a hardware-optimized 9-hit Gaussian), box (using a GPUImageBoxBlurFilter), median (using a GPUImageMedianFilter), and a bilateral blur (using a GPUImageBilateralBlurFilter).
I describe the shaders used to pull off the hardware-optimized Gaussian blur in this answer, and you can examine the code I use for the rest within the framework. These filters run tens of times faster than any CPU-bound routine I've tried yet.
I've also incorporated these blurs into multi-stage processing effects, like unsharp masking, tilt-shift filtering, Canny edge detection, and Harris corner detection, all of which are available as filters within this framework.
再次,为了拯救所有 iOS 模糊问题,这是我的贡献:
https://github.com/tomsoft1/ StackBluriOS
一个基于Stack Blur的简单模糊库。堆栈模糊与高斯模糊非常相似,但速度更快(请参阅 http://incubator.quasimondo.com /processing/fast_blur_deluxe.php )
像这样使用它:
希望这有帮助
Again, in an attempt to save all iOS blur isses, here is my contribution:
https://github.com/tomsoft1/StackBluriOS
A simple blur library based on Stack Blur. Stack Blur is very similar to Gaussian Blur, but much faster (see http://incubator.quasimondo.com/processing/fast_blur_deluxe.php )
use it like this:
Hope this help
我也很失望地发现 iOS 中的 Core Image 不支持模糊。这是我编写的用于在 UIImage 上执行 9-tap 高斯模糊的函数。反复调用以获得更强的模糊效果。
只需在现有图像上调用它,如下所示:
并重复它以获得更强的模糊效果,如下所示:
I too was disappointed to find that Core Image in iOS doesn't support blurs. Here's the function I wrote to do a 9-tap Gaussian blur on a UIImage. Call it repeatedly to get stronger blurs.
Just call it on an existing image like this:
and repeat it to get stronger blurring, like this:
不幸的是,它不支持任何模糊。为此,您必须自己推出。
Unfortunately, it does not support any blurs. For that, you'll have to roll your own.
更新:从 iOS 6 开始,
[CIFilter filterNamesInCategory:kCICategoryBlur];
返回CIGaussianBlur
意味着该过滤器在设备上可用。尽管这是事实,但使用 GPUImage 您(可能)将获得更好的性能和更大的灵活性。UPDATE: As of iOS 6
[CIFilter filterNamesInCategory:kCICategoryBlur];
returnsCIGaussianBlur
meaning that this filter is available on the device. Even though this is true, you (probably) will get better performance and more flexibility using GPUImage.这是我们使用不同方法在 iOS 应用程序中制作模糊效果的教程的链接。 http://blog. denivip.ru/index.php/2013/01/blur-effect-in-ios-applications/?lang=en
Here is the link to our tutorial on making blur effect in iOS application with different approaches. http://blog.denivip.ru/index.php/2013/01/blur-effect-in-ios-applications/?lang=en
如果您可以在 iOS 应用程序中使用 OpenGL ES,则可以通过以下方式计算您选择的像素邻域半径的中值(当然,中值是一种模糊类型):
步骤的简要说明
1. 计算3x3邻域内源像素周围像素值的平均值;
2. 找出同一邻域内所有像素中小于平均值的最大像素值。
3. [可选] 从源像素值中减去中值像素值以进行边缘检测。
如果您使用中值进行边缘检测,有几种方法可以修改上述代码以获得更好的结果,即混合中值过滤和截断媒体过滤(替代和更好的“模式”过滤)。如果您有兴趣,请询问。
If you can use OpenGL ES in your iOS app, this is how you calculate the median in a pixel neighborhood radius of your choosing (the median being a type of blur, of course):
A brief description of the steps
1. Calculate the mean of the values of the pixels surrounding the source pixel in a 3x3 neighborhood;
2. Find the maximum pixel value of all pixels in the same neighborhood that are less than the mean.
3. [OPTIONAL] Subtract the median pixel value from the source pixel value for edge detection.
If you're using the median value for edge detection, there are a couple of ways to modify the above code for better results, namely, hybrid median filtering and truncated media filtering (a substitute and a better 'mode' filtering). If you're interested, please ask.
因为我使用的是 Xamarin,所以我将 John Stephen 的答案转换为 C#:
Because I'm using Xamarin, I converted John Stephen's answer to C#: