简体   繁体   English

如何使用 colormatrix 在 C# 中使用 Reference Color 对图像 (jpg/png) 进行颜色校准

[英]How color Calibrate image (jpg/png) with Reference Color in C# using colormatrix

I have image which has object for reference.我有图像,其中有 object 供参考。 eg Rectangle at a particular position.例如特定 position 处的矩形。

For (Rectnangle) we already have it's ideal/reference color values eg R=255, G=255, B= 255.对于 (Rectnangle),我们已经有了它的理想/参考颜色值,例如 R=255、G=255、B=255。

Mean RGB of Reactangle is something different eg R=200,G=200,B=200. Reactangle 的平均 RGB 是不同的,例如 R=200,G=200,B=200。

So there is R=55,G=55,B=55 deviation from ideal/reference color.因此与理想/参考颜色存在 R=55、G=55、B=55 偏差。

How do use color-matrix to fill this gap of color so that I will get calibrated image?如何使用颜色矩阵来填充这个颜色间隙,以便获得校准图像?

Please suggest, if any better approch rather than this.请建议,如果有更好的方法而不是这个。

you would calculate the quotient of the two colors, ie 255 / 200, and input this in the diagonal values in the color matrix.您将计算两个 colors 的商,即 255 / 200,并将其输入到颜色矩阵的对角线值中。 ie IE

var cr = referenceRed/ actualRed;
...
float[][] colorMatrixElements = { 
   new float[] {cr,  0,  0,  0, 0},        // red scaling factor
   new float[] {0,  cg,  0,  0, 0},        // green scaling factor
   new float[] {0,   0,  cb, 0, 0},        // blue scaling factor
   new float[] {0,   0,  0,  1, 0},        // alpha scaling factor of 1
   new float[] {0,   0,  0,  0, 1}};   

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM