iphone - How do I perform a fast pixellation filter on an image? -


i have little problem pixellation image processing algorithm.

i load image beginning array of type unsigned char* after that, when needed, modify data , have update image. updating takes long. how doing it:

cgdataproviderref dataprovider = cgprovidercratewithdata(.....); cgimageref cgimage = cgimagecreate(....); [imageview setimage:[uiimage imagewithcgimage:cgimage]]]; 

everything working it's slow process large image. tried running on background thread, didn't help.

so basically, takes long. have idea how improve it?

as others have suggested, you'll want offload work cpu gpu in order have kind of decent processing performance on these mobile devices.

to end, i've created an open source framework ios called gpuimage makes relatively simple kind of accelerated image processing. require opengl es 2.0 support, every ios device sold last couple of years has (stats show 97% of ios devices in field do).

as part of framework, 1 of initial filters i've bundled pixellation one. simplevideofilter sample application shows how use this, slider controls pixel width in processed image:

screenshot of pixellation filter application

this filter result of fragment shader following glsl code:

 varying highp vec2 texturecoordinate;  uniform sampler2d inputimagetexture;  uniform highp fractionalwidthofpixel;   void main()  {     highp vec2 sampledivisor = vec2(fractionalwidthofpixel);      highp vec2 samplepos = texturecoordinate - mod(texturecoordinate, sampledivisor);     gl_fragcolor = texture2d(inputimagetexture, samplepos );  } 

in benchmarks, gpu-based filters perform 6-24x faster equivalent cpu-bound processing routines images , video on ios. above-linked framework should reasonably easy incorporate in application, , source code freely available customize see fit.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -