color correction of camera output
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have an image that taken from manually controlled color options camera. it has some error about colors. i tried to fix them by taking 3 different pixel of the image and took also these 3 pixels real values in terms of rgb values. and i get a 3x3 matrix to correct the hole image. it is basicly working. i get some good result but i have to correct totally. how can i fix the images color. output of my image
after my process
how can i fix these errors
7 Kommentare
Kevin Claytor
am 4 Jul. 2012
1) Dude, it's been an hour, chill out. 2) Are you using the image acquisition toolbox to get the images? I know there's a property where you can change the HSB / RGB values of the camera. After you initalize the camera you can go to get(vid) to see all the properties. Something in there will allow you to adjust the color. Use preview(vid) to see how it looks.
Antworten (1)
Image Analyst
am 4 Jul. 2012
Bearbeitet: Image Analyst
am 4 Jul. 2012
I have color correction code (as everyone might expect). It's robust and versatile but it's almost 1000 lines long. Basically it looks like you're trying to do RGB-to-RGB color correction using a "linear single channel" model with no offset. I know the ICC color profiles use that model but it is very primitive and professional color correction software uses better models. I guess you'd also agree since you say your result is not good enough. This primitive model could be fine in some situations, but for more accuracy you might want to add a constant term to your model, and possibly higher order terms and cross channel terms. So to add a constant term to your model, your matrix in your least squares model would be
1 R1 G1 B1
1 R2 G2 B2
1 R3 G3 B3
...
1 RN GN BN
You could even go to higher order like quadratic and include cross terms like R*G to get better correction. N should be more than 3 points like you use. You should have around 20-30 points (actual pixel colors) in the image to train your model, and the "desired" values for each of those actual pixel colors. Have you considered using the X-rite Color Checker Chart? It's an industry standard for color correction. I usually use a linear cross channel correction if I just expect things like intensity changes but sometimes use a quadratic cross channel model if I think there might be a change in the color temperature of the lighting. If you go higher, like cubic, then you'll get better correction at the training colors but for all other colors the corrected colors tend to blow up and go haywire, just like any higher order fitting that you're familiar with. A linear cross channel model would look like:
1 R1 G1 B1 R1*G1 R1*B1 G1*B1
1 R2 G2 B2 R2*G2 R2*B2 G2*B2
1 R3 G3 B3 R3*G3 R3*B3 G2*B3
...
1 RN GN BN RN*GN RN*BN GN*BN
Of course you'd have one regression for each color, plugging in the actual reds and the desired reds, the actual greens and the desired green, and the actual blues and the desired blues. So you get three sets of coefficients out alpha, beta, and gamma. To get your corrected red color for some arbitrary test pixel you'd do
correctedRed = alpha(1) + alpha(2)*Rtest + alpha(3)*Gtest + alpha(4)*Btest + alpha(5)*Rtest*Gtest + alpha(6)*Rtest*Btest + alpha(7)*Gtest*Btest
Disclaimer - I think that's right but I didn't consult my code. Anyway, then you do the same with beta to get the corrected green and with the gamma to get the corrected blue:
correctedGreen = beta(1) + beta(2)*Rtest + beta(3)*Gtest + beta(4)*Btest + beta(5)*Rtest*Gtest + beta(6)*Rtest*Btest + beta(7)*Gtest*Btest
correctedBlue = gamma(1) + gamma(2)*Rtest + gamma(3)*Gtest + gamma(4)*Btest + gamma(5)*Rtest*Gtest + gamma(6)*Rtest*Btest + gamma(7)*Gtest*Btest
2 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!