1

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?

Matthew Simoneau
  • 6,199
  • 6
  • 35
  • 46
space
  • 93
  • 2
  • 4

2 Answers2

0

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)];
Nathan Eror
  • 12,418
  • 2
  • 29
  • 19
0

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.

Community
  • 1
  • 1
madmik3
  • 6,975
  • 3
  • 38
  • 60