PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, May 6, 2022

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

 May 06, 2022     c#, colormatrix, image, image-manipulation, image-processing     No comments   

Issue

I have image which has object for reference. e.g. Rectangle at a particular position.

For (Rectnangle) we already have it's ideal/reference color values e.g. R=255, G=255, B= 255.

Mean RGB of Reactangle is something different e.g. R=200,G=200,B=200.

So there is R=55,G=55,B=55 deviation from ideal/reference color.

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.


Solution

you would calculate the quotient of the two colors, i.e. 255 / 200, and input this in the diagonal values in the color matrix. i.e.

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}};   



Answered By - JonasH
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing