【发布时间】:2021-06-08 11:29:33
【问题描述】:
我正在使用WICConvertBitmapSource 函数将像素格式从 BGR 转换为灰色,我得到了意想不到的像素值。
...
pIDecoder->GetFrame( 0, &pIDecoderFrame );
pIDecoderFrame->GetPixelFormat( &pixelFormat ); // GUID_WICPixelFormat24bppBGR
IWICBitmapSource * dst;
WICConvertBitmapSource( GUID_WICPixelFormat8bppGray, pIDecoderFrame, &dst );
4x3 图像示例,包含以下内容 BGR 像素值:
[ 0, 0, 255, 0, 255, 0, 255, 0, 0;
0, 255, 255, 255, 255, 0, 255, 0, 255;
0, 0, 0, 119, 119, 119, 255, 255, 255;
233, 178, 73, 233, 178, 73, 233, 178, 73]
我得到的灰色像素值:
[127, 220, 76;
247, 230, 145;
0, 119, 255;
168, 168, 168]
我期望得到的灰色像素值 (ITU-R BT.601 conversion)
[ 76, 149, 29;
225, 178, 105;
0, 119, 255;
152, 152, 152]
后台发生了什么样的转换,有没有办法强制转换为我想要的行为?
另外值得一提的是,Gray -> BGR 和 BGRA -> BGR 的转换工作正常(如预期)
【问题讨论】:
标签: c++ windows image-processing imaging color-space