How to create simple custom filter for iOS using Core Image Framework?

You can't create your own custom kernels/filters in iOS yet. See developer.apple.com/library/mac/#documen... specifically.

Up vote 0 down vote favorite share g+ share fb share tw.

I want to use in my app an custom filter. Now I know that I need to use Core Image framework, but I not sure that is right way. Core Image framework uses for Mac OS and in iOS 5.0 - I'm not sure that could be used for custom CIFilter effects.

Can you help me with this issues? Thanks all! Ios image-processing core-image link|improve this question asked Jan 17 at 14:03Matrosov Alexander344111 72% accept rate.

You can't create your own custom kernels/filters in iOS yet. See developer.apple.com/library/mac/#documen..., specifically: Although this document is included in the reference library, it has not been updated in detail for iOS 5.0. A forthcoming revision will detail the differences in Core Image on iOS.

In particular, the key difference is that Core Image on iOS does not include the ability to create custom image filters. (Bolding mine).

Note that although you can't write your own kernels, it may be possible to combine existing CIFilters to get the effect you want. What effect are you trying to create? – user1118321 Jan 17 at 14:14 Indeed.

You can also write your own image filter functions entirely yourself, operating directly on the data. If you use the Accelerate framework wisely, you'll also get significant hardware support for this. – Adam Wright Jan 17 at 14:17.

As Adam states, currently Core Image on iOS does not support custom kernels like the older Mac implementation does. This limits what you can do with the framework to being some kind of combination of existing filters. (Update: 2/13/2012) For this reason, I've created an open source framework for iOS called GPUImage, which lets you create custom filters to be applied to images and video using OpenGL ES 2.0 fragment shaders.

I describe more about how this framework operates in my post on the topic. Basically, you can supply your own custom OpenGL Shading Language (GLSL) fragment shaders to create a custom filter, and then run that filter against static images or live video. This framework is compatible with all iOS devices that support OpenGL ES 2.0, and can create applications that target iOS 4.0.

For example, you can set up filtering of live video using code like the following: GPUImageVideoCamera *videoCamera = GPUImageVideoCamera alloc initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack; GPUImageFilter *customFilter = GPUImageFilter alloc initWithFragmentShaderFromFile:@"CustomShader"; GPUImageView *filteredVideoView = GPUImageView alloc initWithFrame:CGRectMake(0.0, 0.0, viewWidth, viewHeight); // Add the view somewhere so it's visible videoCamera addTarget:thresholdFilter; customFilter addTarget:filteredVideoView; videoCamera startCameraCapture; As an example of a custom fragment shader program that defines a filter, the following applies a sepia tone effect: varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; void main() { lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate); lowp vec4 outputColor; outputColor. R = (textureColor. R * 0.393) + (textureColor.

G * 0.769) + (textureColor. B * 0.189); outputColor. G = (textureColor.

R * 0.349) + (textureColor. G * 0.686) + (textureColor. B * 0.168); outputColor.

B = (textureColor. R * 0.272) + (textureColor. G * 0.534) + (textureColor.

B * 0.131); gl_FragColor = outputColor; } The language used for writing custom Core Image kernels on the Mac is very similar to GLSL. In fact, you'll be able to do a few things that you can't in desktop Core Image, because Core Image's kernel language lacks some things that GLSL has (like branching).

Thanks for your answer! Yes, if use openGL this is best result for me. But now I have a little knowledges about this features in openGL – Matrosov Alexander Jan 19 at 11:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions