提取UIImage的青色通道?

时间:2014-10-03 06:27:14

标签: ios uiimage

我想知道,是否可以将UIImage的青色频道提取到单独的UIImage?有点像在Photoshop中,你可以点击显示青色的标签,它显示图像的青色通道。这甚至可能吗?

1 个答案:

答案 0 :(得分:0)

通过修改this answer,您可以获得一些东西。

CFDataRef pixelData = CGDataProviderCopyData(CGImageGetDataProvider(image.CGImage));
const UInt8* pixelBytes = CFDataGetBytePtr(pixelData);

int cyanChannel = 0;
//32-bit RGBA
for(int i = 0; i < CFDataGetLength(pixelData); i += 4) {
    cyanChannel += pixelBytes[i + 1] + pixelBytes[i + 2]; // cyan = green + blue
}