Need help Optimizing Sharpen and Blur in iPhone Application

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
DrJOnes666

Need help Optimizing Sharpen and Blur in iPhone Application

Post by DrJOnes666 »

Hi,
I am an iphone app developer and we are currently working on an application that use Image Magick for some graphical modifications. Our programmer is currently testing ways to optimize the workflow of the Image Magick filters inside our application. So far, he was able to reduce to 7 seconds the rendering time of many of the effects such as Saturations on a 5MP image on an iphone 4. Unfortunately, other effects are taking much longer, such as Blur (15s) and Sharpen (20s), which we would like to reduce the rendering time as much as possible.

My questions are:
- does all sharpen and blur effects in the IMage Magick database take roughly the same time to render on an image? (in Photoshop for instance, Smart Sharpen takes considerably longer to render than a regular Unsharp Mask).
- what would be the best ways to optimize those effects in an iphone app?
- do you know links/references I could offer our programmer to educate himself on the subject of optimizing IM effects inside an iphone app?

Thank you all!

Martin
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Need help Optimizing Sharpen and Blur in iPhone Applicat

Post by magick »

Pushing pixels is computationally expensive. In particular, blur and sharpen are convolution filters that take a neighborhood of pixels about each pixel of interest which is quite costly. If your image is 1000x1000 and your convolution filter is 5x5, that's 25 million operations. If the image is 4000x4000 it exceeds 400 million operations. On top of that, the operations are floating point. We're not sure if floating point is performed in hardware or software on the iPhone. ImageMagick speeds up these algorithms with two methods: OpenMP and OpenCL. OpenMP allows loops in ImageMagick to run in parallel and OpenCL permits convolution to be performed in a SIMD fashion on a compatible co-processor (e.g. NVidia graphics card). Neither of these options are supported on the iPhone. Chances are, the most promising speed-up on the iPhone is refactoring certain algorithms into assembly.

If there are any iPhone experts on the list that can recommend a path forward for optimizing ImageMagick for that platform, please post here.
3DTOPO
Posts: 28
Joined: 2010-07-05T16:13:53-07:00
Authentication code: 8675308

Re: Need help Optimizing Sharpen and Blur in iPhone Applicat

Post by 3DTOPO »

Greetings,

iOS 4 added an Accelerate framework, that according to Apple:
...the Accelerate Framework, which contains C APIs for vector and matrix math, digital signal processing, large number handling, and image processing.
Documentation and sample code is here:
http://developer.apple.com/library/ios/ ... index.html

I would be interested in working on this, not sure where to begin however.

Any suggestions? Does anyone care to collaborate?
DrJOnes666

Re: Need help Optimizing Sharpen and Blur in iPhone Applicat

Post by DrJOnes666 »

Thanks for the info! Much appreciated!

Indeed, if there was any way to accelerate that process of rendering on the iphone, it would be a great improvement for app possibilities!! I wish I knew how to code! ;-)
Post Reply