自定义CIPixellate过滤器的颜色选择

时间:2012-12-22 17:51:48

标签: ios core-image cifilter

用户选择的图像基于滑块输入或多或少地进行像素化:

-(CIImage *)pixelPhoto:(CIImage *)img withAmount:(float)inputScale {

// Set up the pixellate filter where the inputScale is provided by the slider.
CIFilter *pixel = [CIFilter filterWithName:@"CIPixellate"];
[pixel setValue:img forKey:kCIInputImageKey];
[pixel setValue:[NSNumber numberWithDouble:inputScale] forKey:@"inputScale"];
CIImage *croppedImage = [pixel.outputImage imageByCroppingToRect:[beginImage extent]];
return croppedImage; }

据我所知,它通过将图像映射到颜色由替换像素定义的彩色方块来使图像变得模糊。 (CIFilter Class Reference)想象一下按数字绘制的场景;我想更深入地了解CIPixellate,然后将每个正方形的颜色近似为约400种颜色的较小阵列。

这是我第一次尝试操纵图像,或者真的在使用任何类型的图形。我想我找到我需要的信息并不是很幸运,因为我不知道有足够的正确术语来正确搜索。

似乎我应该能够从像素化的图像数据中拉出正方形颜色的数组,然后迭代它们以应用算法将它们近似到我想限制它们的较短颜色列表。有什么建议吗?

0 个答案:

没有答案