简体   繁体   中英

Help with image processing in an iPhone app

I'm working with an image processing tool in MATLAB. How can I convert MATLAB code to Objective-C?

Here are some of the tasks I want to do:

  • I want to rotate an oblique line to normal.

  • I have algorıthm that converts an colored image to black & white. (How can I access pixel color values in Objective-C?)

  • In the function getrgbfromimage , how can I access output of pixel values to consol?

  • How can I run a function ( getrotatedımage ) on each element of an array?

Quartz 2D (aka. Core Graphics) is the 2D drawing API in iOS. Quartz will, most likely, do everything you're looking for. I recommend checking out the Quartz 2D Programming Guide in the documentation. For your specific requests check out these sections:

  • Colors and Color Spaces - for color and b&w images
  • Transforms - for rotating or performing any affine transform
  • Bitmap Images and Image Masks - for information on the underlying image data

As for running a function on each element of an array, you can use the block iteration API (as long as your app can require iOS 4.0 or higher). An example:

[myArray enumerateObjectsUsingBlock:^(id item, NSUInteger index, BOOL *stop) {
  doSomethingWith(item);
}];

If you just want to call a method on each item in the array, there is also:

[myArray makeObjectsPerformSelector:@selector(doSomething)];

CGBitmapContext will get pixel values from an image.

http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGBitmapContext/Reference/reference.html

This has same demo code.

Retrieving a pixel alpha value for a UIImage (MonoTouch)

printf will dump the RGB values to the console.

NSArray or NSMutableArray will hold your images and a simple for loop will let you iterate through them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM