Chapter 10. Drawing with Core Image


Core Image is one of the most exciting technologies that Apple has added to its Mac OS X 10.4 Tiger operating system. The Core Image library ties together a number of graphics technologies on the platform and makes them available to your application in a single, easy to use interface. In its initial incarnation, Core Image is a toolkit for creating image effects and filters that modify images very quickly. The library draws its performance from the fact that it takes advantage of all the special hardware that it can. If you have a processor with a vector processing unit, Core Image will make use of it applying effects. If you have a programmable graphics card, the library can use that as well. In fact, with high-speed hardware, Core Image can apply effects to full-motion video in real time as it plays. What's more, if the drawing effects are applied by a programmable graphics card, the entire process will require surprisingly little CPU time. Core Image is the epitome of the modern graphics APIs on Mac OS X. It provides incredible power that is easy to access.

Like QuickTime, Core Image has a modular architecture. The set of filters in Core Image is extensible. The library itself ships with dozens of image filters and transitions. Developers can create additional filters, called Image Units, which can extend the set of filters if the default set is not sufficient.

Core Image is a sufficiently complex technology that it would take an entire book to explore thoroughly. Unfortunately this book will not be able to cover some of the intricate details of creating custom Core Image Filters. The purpose here is to explore the basic features of Core Image and describe the capabilities of the framework. You will see how an application can set up a series of Core Image Filters to create an image effect and then ask the computer to apply that effect when drawing an image.

Additional Image Processing Support

Core Image is not the only image processing library in Mac OS X. For example, QuickTime contains a number of effects and transitions that are, in many ways, simliar to those found in Core Image. It is quite likely that Apple will change the implementation of QuickTime effects to use Core Image filters in the future. QuickTime effects and transitions work well in the context of creating a movie, but the API can be a bit cumbersome when applying effects to images in a simple, still-image drawing context.

Mac OS X also contains the Accelerate Framework. This umbrella framework contains sub-frameworks that you might apply to image processing. One of the sub-frameworks, vImage, is specifically geared toward image processing. The routines in the Accelerate Framework are particularly well suited to image processing used to extract analytical information from an image. For example, vImage can generate the histogram of an image. The routines in the signal processing framework (vDSP) might be handy if your application wants to perform a Fast Fourier Transform on an image for processing in the frequency domain.

From a less programmer-oriented perspective, there are some high-level tools for image processing on the system. The ColorSync Utility application in /Application/ Utilities can open image files and apply image filters and color space transformations to an image file. From the command line there is a service called sips (the Scriptable Image Processing System) that will allow you to retrieve information from image files and manipulate their contents (issue the command sips --help from a terminal window). This same functionality is exposed to AppleScript scripts through the Image Events scriptable application.

With such a long and rich history in computer graphics, Mac OS X the system contains a lot of useful functionality. Exploring some of the corners of the system to see what you can find is not only fun, but it might also save you a lot of time and trouble. Spend some time exploring these other image processing libraries, and you may like what you find.





Quartz 2D Graphics for Mac OS X Developers
Quartz 2D Graphics for Mac OS X Developers
ISBN: 0321336631
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net