简体   繁体   English

帮助iPhone应用程序中的图像处理

[英]Help with image processing in an iPhone app

I'm working with an image processing tool in MATLAB. 我正在使用MATLAB中的图像处理工具。 How can I convert MATLAB code to Objective-C? 如何将MATLAB代码转换为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?) (如何在Objective-C中访问像素颜色值?)

  • In the function getrgbfromimage , how can I access output of pixel values to consol? 在功能getrgbfromimage ,如何将像素值的输出访问到consol?

  • How can I run a function ( getrotatedımage ) on each element of an array? 如何在数组的每个元素上运行函数( getrotatedımage )?

Quartz 2D (aka. Core Graphics) is the 2D drawing API in iOS. Quartz 2D(又名Core Graphics)是iOS中的2D绘图API。 Quartz will, most likely, do everything you're looking for. Quartz很可能会做您想要的一切。 I recommend checking out the Quartz 2D Programming Guide in the documentation. 我建议您查阅文档中的《 Quartz 2D编程指南 》。 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). 至于在数组的每个元素上运行函数,您可以使用块迭代API(只要您的应用程序需要iOS 4.0或更高版本)。 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. CGBitmapContext将从图像获取像素值。

http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGBitmapContext/Reference/reference.html 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) 检索UIImage的像素alpha值(MonoTouch)

printf will dump the RGB values to the console. printf会将RGB值转储到控制台。

NSArray or NSMutableArray will hold your images and a simple for loop will let you iterate through them. NSArray或NSMutableArray将保存您的图像,而简单的for循环将允许您遍历它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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