ios basic image processing extract red channel

两盒软妹~` 提交于 2019-12-04 06:27:48

问题


straight forward I need to extract color components from an image, usually in Matlab this is done choosing the first matrix for Red.

In the realm of accelerate framework, which documentation is reference-based I can't find an easy way of doing this without resolving to graphics context.

Thanks in advance!!


回答1:


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

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


来源:https://stackoverflow.com/questions/13264802/ios-basic-image-processing-extract-red-channel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!