格式化CIColorCube数据 [英] Formatting CIColorCube data

查看:128
本文介绍了格式化CIColorCube数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我一直在尝试在CIImage上设置CIColorCube以创建自定义效果。这就是我现在所拥有的:

Recently, I've been trying to set up a CIColorCube on a CIImage to create a custom effect. Here's what I have now:

uint8_t color_cube_data[8*4] = {
    0, 0, 0, 1,
    255, 0, 0, 1,
    0, 255, 0, 1,
    255, 255, 0, 1,
    0, 0, 255, 1,
    255, 0, 255, 1,
    0, 255, 255, 1,
    255, 255, 255, 1
};
NSData * cube_data =[NSData dataWithBytes:color_cube_data length:8*4*sizeof(uint8_t)];
CIFilter *filter = [CIFilter filterWithName:@"CIColorCube"];
[filter setValue:beginImage forKey:kCIInputImageKey];
[filter setValue:@2 forKey:@"inputCubeDimension"];
[filter setValue:cube_data forKey:@"inputCubeData"];
outputImage = [filter outputImage];

我已经查看了WWDC 2012核心图像会话,我仍然无法正常工作。我也检查了网络,在这个问题上可用的资源非常少。我上面的代码只返回一张黑色图片。

I've checked out the WWDC 2012 Core Image session, and what I have still doesn't work. I've also checked the web, and there are very few resources available on this issue. My code above just returns a black image.

在Apple的开发人员库,它说:

In Apple's developer library, it says:


此过滤器将RGB空间的映射应用于inputCubeData中定义的新颜色值。对于inputImage中的每个RGBA像素,过滤器使用R,G和B值来索引由inputCubeData表示的维度纹理。 inputCubeData包含包含线性预乘值的浮点RGBA单元格。数据被组织成inputCubeDimension数量的xy平面,每个平面的大小为inputCubeDimension,由inputCubeDimension提供。输入像素分量R和G分别用于索引x和y中的数据,B用于索引z。在inputCubeData中,R组件变化最快,其次是G,然后是B.

This filter applies a mapping from RGB space to new color values that are defined in inputCubeData. For each RGBA pixel in inputImage the filter uses the R,G and B values to index into a thee dimensional texture represented by inputCubeData. inputCubeData contains floating point RGBA cells that contain linear premultiplied values. The data is organized into inputCubeDimension number of xy planes, with each plane of size inputCubeDimension by inputCubeDimension. Input pixel components R and G are used to index the data in x and y respectively, and B is used to index in z. In inputCubeData the R component varies fastest, followed by G, then B.

然而,这对我来说没有意义。我的 inputCubeData 如何格式化?

However, this makes no sense to me. How does my inputCubeData need to be formatted?

推荐答案

我找到了问题...我已经更新了我的问题,如果有人有同样的问题!

I found the issue... I have updated my question if anyone has the same problem!

输入浮点数组必须预先划分为255。

The input float array had to be pre-divided out of 255.

原来使用的255:

uint8_t color_cube_data[8*4] = {
    0, 0, 0, 1,
    255, 0, 0, 1,
    0, 255, 0, 1,
    255, 255, 0, 1,
    0, 0, 255, 1,
    255, 0, 255, 1,
    0, 255, 255, 1,
    255, 255, 255, 1
};

它应该是这样的:

uint8_t color_cube_data[8*4] = {
    0, 0, 0, 1,
    1, 0, 0, 1,
    0, 1, 0, 1,
    1, 1, 0, 1,
    0, 0, 1, 1,
    1, 0, 1, 1,
    0, 1, 1, 1,
    1, 1, 1, 1
};

这篇关于格式化CIColorCube数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆