標籤:des style blog http io color os ar 使用
ios-image-filters
https://github.com/esilverberg/ios-image-filters
photoshop-style filter interface for UIImage class on iOS to make instagram-style images
photoshop-風格的濾鏡介面,可以像使用photshop那樣子來配置圖片。
ios-image-filters
These days everyone seems to want instagram-style filters for images on iPhone. The way to do this (I think) is to examine how people have implemented equivalent filters in Photoshop and code them in objective c. Unfortunately, the imaging libraries are all geared for gaming. For non-game developers who just want simple image processing, this is overkill.
這些日子裡,大家都想用具備設定風格的濾鏡來處理圖片。為了達到這個目的,大家需要研究Photoshop中使用的濾鏡以及OC代碼中等效的濾鏡,很不幸,這些圖片濾鏡全部都是為遊戲開發設計,對於非遊戲開發人員,即使只想用最簡單的圖片處理,這也無異於自殺。
It‘s like photoshop for the UIImage class!
I‘ve worked hard to mimic the photoshop color adjustment menus. Turns out these are clutch in pretty much all the best image filters you can name right now (lomo, polaroid). For example, if you want to manipulate levels, here‘s your method, built straight onto the UIImage class:
只是類比photoshop的色彩平衡的菜單都費了好大的勁。為了調節到能達到指定的效果花了好多好多時間。不過已經很好用了,你可以看如下的例子:
- (UIImage*) levels:(NSInteger)black mid:(NSInteger)mid white:(NSInteger)white
An API just like that cool menu in Photoshop!
Want to do a curves adjustment to mimic a filter you saw on a blog? Just do this:
一個API與Photoshop中的一個菜單非常相似!
能夠微調一個濾鏡的效果嗎?用以下的方式即可:
NSArray *redPoints = [NSArray arrayWithObjects: [NSValue valueWithCGPoint:CGPointMake(0, 0)], [NSValue valueWithCGPoint:CGPointMake(93, 76)], [NSValue valueWithCGPoint:CGPointMake(232, 226)], [NSValue valueWithCGPoint:CGPointMake(255, 255)], nil];NSArray *bluePoints = [NSArray arrayWithObjects: [NSValue valueWithCGPoint:CGPointMake(0, 0)], [NSValue valueWithCGPoint:CGPointMake(57, 59)], [NSValue valueWithCGPoint:CGPointMake(220, 202)], [NSValue valueWithCGPoint:CGPointMake(255, 255)], nil];UIImage *image = [[[UIImage imageNamed:@"landscape.jpg" applyCurve:redPoints toChannel:CurveChannelRed] applyCurve:bluePoints toChannel:CurveChannelBlue];
The problem with my curves implementation is that I didn‘t use the same kind of curve algorithm as Photoshop uses. Mainly, because I don‘t know how, and other than the name of the curve (bicubic) all the posts and documentation I simply don‘t understand or cannot figure out how to port to iOS. But, the curves I use (catmull-rom) seem close enough.
其實還是有問題的,因為我實現的方式與Photoshop並不一致。主要原因是,我不知道Photoshop的相關濾鏡是怎麼實現出來的,我只能從iOS的找到類似的效果來替換。
How to integrate
Copy and paste the ImageFilter.* and Curves/* classes into your project. It‘s implemented a Category on UIImage.
怎麼使用呢?複製粘貼ImageFilter.*與Curves.*類到你的項目工程中。他們都是UIImage的category的方式實現的,簡單易用。
How to use
#import "ImageFilter.h"UIImage *image = [UIImage imageNamed:@"landscape.jpg"];self.imageView.image = [image sharpen];// Orself.imageView.image = [image saturate:1.5];// Orself.imageView.image = [image lomo];
What is still broken
- Gaussian blur is slow! 高斯模糊很慢!
- More blend modes for layers 更多的針對Layer的混合模式
- Curves are catmull rom, not bicubic ???
- So much else... 就這些...
Other options
I tried, but mostly failed, to understand these libraries. Simple Image Processing is too simple, and uses a CPP class to accomplish its effects, as does CImg. I find the CPP syntax ghoulish, to say the least. I stared at the GLImageProcessing code for hours, and still don‘t understand what‘s going on. Guess I should have taken CS244a...
為了理解這些庫怎麼用,我試過了,但絕大部分都失敗了。簡單的圖片處理是很簡單的,包括用CPP類來實現這些效果,還有CImg。我發現CPP的文法格式太恐怖而放棄了。我嘗試了GLImageProcessing幾個小時候,因為實在不知道他們是怎麼出來效果的-_-!!,也許我該試一下CS244a...
UPDATE: Core image filters in iOS5 are probably what you want to use going forward, though they are not backwards-compatible with iOS4 or earlier.
更新:在iOS5上,Core image濾鏡就是你以後要使用的工具了,雖然他們不會向前相容iOS4之前的版本。
- Core Image Filters:http://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CoreImageFilterReference/Reference/reference.html
- Simple Image Processing: http://code.google.com/p/simple-iphone-image-processing/
- GLImageProcessing:http://developer.apple.com/library/ios/#samplecode/GLImageProcessing/Introduction/Intro.html
- CImg: http://cimg.sourceforge.net/reference/group__cimg__tutorial.html
License
MIT License, where applicable. I borrowed code from this project:http://sourceforge.net/projects/curve/files/ , which also indicates it is MIT-licensed.http://en.wikipedia.org/wiki/MIT_License
There is also now code adapted from ImageMagick, whose license may be found at:http://www.imagemagick.org/script/license.php
[翻譯] ios-image-filters