To facilitate the operation of image classes defined in iOS, uiimage is an image class defined in the uikit framework. It encapsulates high-level image classes and can be created in multiple ways. cgimage is also defined in the core graphics framework (or quartz 2d). cgimage represents a bitmap image. cgimage is encapsulated, so cgimageref is usually used to use cgimage.
In addition to uiimage and cgimage, there is also an image class ciimage in the core image framework. ciimage encapsulates the image class for better image processing. for example, the use of filters. uiimage, cgimage, and ciimage can be converted between each other, involving conversion from C to OC objects. If the arc technology is used here, pay attention to the memory release issue.
Core image framework
Core image is a very important framework in image processing. core image is used to process and analyze images in real time. It can process images from core graphics, core video, and image I/O and other framework data types. and uses the CPU or GPU for rendering. The core image can shield many low-level technical details, such as OpenGL ES and GCD.
The core image framework has the following important classes:
Ciimage, image class in core image framework
Cicontext: context object. All image processing is completed in one cicontext. ciimage objects are rendered using quartz 2D and OpenGL.
Cifilter, the filter class contains a dictionary structure that defines the attributes of various filters.
Cidetector is a facial recognition class that uses cifacefeature to identify the locations of the mouth and eyes.
Ciimage is the most common class in the core image framework. It has some constructor methods and static creation methods.
+ (Ciimage *) imagewithcgimage :( cgimageref) image; // The static creation method. You can use cgimageref to create an image object + (ciimage *) imagewithcontentsofurl :( nsurl *) URL; // The static creation method, create an image object + (ciimage *) imagewithdata :( nsdata *) data; // create an image object using the nsdata object in the memory-(ID) initwithcgimage :( cgimageref) image; // constructor: creates an image object through the cgimageref object in the memory-(ID) initwithdata :( nsdata *) data; // constructor, create an image object-(ID) initwithcontentsofurl :( nsurl *) URL through the nsdata object in the memory; // construction method, and create an image object through the file path object
Cicontext * context = [cicontext contextwitexceptions: Nil]; // create the context ciimage * cimage = [ciimage imagewithcgimage: [_ image cgimage]; ciimage * result; cifilter * sepiatone = [cifilter filterwithname: @ "cisepiatone"]; // create a filter [sepiatone setvalue: cimage forkey: @ "inputimage"]; double value = [_ slider value]; nsstring * text = [[nsstring alloc] initwithformat: @ "Old intensity: %. 2f ", value]; _ label. TEXT = text; [text release]; [sepiatone setvalue: [nsnumber numberwithfloat: value] forkey: @ "inputintensity"]; // set the value result = [sepiatone valueforkey: @ "outputimage"]; // output cgimageref imageref = [context createcgimage: Result fromrect: cgrectmake (0, 0, self. imageview. image. size. width, self. imageview. image. size. height)]; uiimage * image = [[uiimage alloc] initwithcgimage: imageref]; _ imageview. image = image; cfrelease (imageref); // remember to release [Image release];
<Graphic images, animations, multimedia> Reading Notes-Image Processing