您的位置:首页 > 其它

简单的iphone图片处理程序

2011-10-14 14:09 260 查看
原文出处:http://code.google.com/p/simple-iphone-image-processing/

  申明:本博文内容来自于互联网,如因本文内容而发生的一切纠纷,均与本文章的翻译者无关。翻译质量因本人水平,有所限制。欢迎批评指正。本文章仅供参考、学习、交流之用,禁止用于任何商业用途。转载时请保留原文出处与保留本申明,多谢合作!

  我写了一个简单的C++类并用Objective-C包装好以防我们要设置的公用图片来自于UIImage或是要转换成UIImage。

  这个源码支持以下的所有操作

  精细的边沿检测:http://en.wikipedia.org/wiki/Canny_edge_detection

  均匀的直方图:  http://en.wikipedia.org/wiki/Histogram_equalisation  

拓扑骨架: http://en.wikipedia.org/wiki/Topological_skeleton

  阈值、自适应与总体参数: http://en.wikipedia.org/wiki/Thresholding_(image_processing)

亮度正常化: http://en.wikipedia.org/wiki/Normalization_(image_processing)

区间截取: ttp://en.wikipedia.org/wiki/Blob_extraction

尺寸重设(使用插值)

你可以给它传送一个UIImage,它会把UIImage转换成一幅灰度图片,为后期的图片处理做准备。现在,我会简短地讲一讲如何在一张图片中控制“绿色通道”(我的图片是要做成一张报纸,所以它没有颜色)。你可能会取消红、绿、蓝通道的平均水平线
在示例工程中,你可以加入你的图片到工程中,它们会显示在待处理的图片列表中。

这些类的 典型应用如下:

// convert to grey scale and shrink the image by 4 - this makes processing a lot faster!
ImageWrapper *greyScale=Image::createImage(srcImage, srcImage.size.width/4, srcImage.size.height/4);

// do a gaussian blur and then extract edges using the canny edge detector
// you can play around with the numbers to see how it effects the edge extraction
// typical numbers are  tlow 0.20-0.50, thigh 0.60-0.90
ImageWrapper *edges=greyScale.image->gaussianBlur().image->cannyEdgeExtract(0.3,0.7);
// show the results
resultImage.image=edges.image->toUIImage();


用Objective-C封装好的类,会很小心地管理你的内存,所有的C++类都会直接返回给你封装好的对象或直接对图片进行处理。

这些源码最近被我用到了一个iPhone的数独表工程上http://sudokugrab.blogspot.com/ ,当前它也可以扩展到其它的项目里面。

svn checkout http://simple-iphone-image-processing.googlecode.com/svn/trunk/

你也可以看一下此类的工程,它会在类似这样的的情况下被使用http://www.youtube.com/watch?v=oImMJ6p6mKE
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: