ios basic image processing extract red channel

前端 未结 1 1015
無奈伤痛
無奈伤痛 2021-01-27 08:14

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 framewor

相关标签:
1条回答
  • 2021-01-27 08:35
    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
    }
    
    0 讨论(0)
提交回复
热议问题