GammaCorrection/ White balance

7 次查看(过去 30 天)
azarm
azarm 2012-4-16
回答: DGM 2023-10-2
hey everybody,
i have an RGB image, which needs a white balance. As i make it linear, overexposure happens (especially in the sky area)! anybody knows how can i make a logarithmic correction considering the gamma?! tnx in advance,
cheers, Azarm

回答(3 个)

Image Analyst
Image Analyst 2012-4-16
Use the "Curves" tool in Photoshop. Or, I really like the highlights and shadows tool.
Or, you can do trial and error by multiplying your image by the gamma function ( http://en.wikipedia.org/wiki/Gamma_correction). Be sure to adjust the amplitude to take into account that the different channels have different values for the white region. For example what you want to be white is (230, 200, 170) and so the gamma function will need to be different if you want to end up with white at (245,245,245) or whatever. I wouldn't go all the way to 255 because otherwise there may be some pixels that get saturated.
Or you can do it the best, but most difficult, way and that is to take a picture of a Color Checker chart ( http://en.wikipedia.org/wiki/ColorChecker) and derive the transform to map your input color image into the desired color image. The math is too involved to post here, but I've done it in MATLAB.
  3 个评论
Image Analyst
Image Analyst 2017-5-25
Start a new question, and try to explain it better. It makes little sense to make it such that all the gray chips will have the same RGB value. In that case, the entire image will have the same RGB value, and what good is that?
zouhair jimmouh
zouhair jimmouh 2017-5-25
Dear Image Analyst ! thank you for taking the time to answer me.
here is my question.

请先登录,再进行评论。


Mahmoud Afifi
Mahmoud Afifi 2019-8-12

DGM
DGM 2023-10-2
Considering that we're talking about the Photoshop curves tool, imadjust() does simple power-law gamma adjustment without the need for reinventing wheels or dealing with class-dependent data scale.
% perhaps this is a bit excessive for sake of emphasis,
% the white page background is unhelpful
inpict = imread('tire.tif'); % since we're talking about wheels
outpict = imadjust(inpict,[0 1],[0 1],0.5);
% compare the two images
combined = [inpict outpict];
imshow(combined,'border','tight')
Of course, the PS curves tool can do more than just a simple power-law gamma curve. MIMT imlnc() offers some more options to shape the curve. We can bend the curve back toward linear at the top end to try to retain some highlight contrast.
outpict = imlnc(inpict,'in',[0 1],'g',0.6,'k',0.8);
For an arbitrary curve, you'd use imcurves() (or interp1() and a bunch of ancillary stuff).
% a similar curve
x = [0 0.065 0.15 0.40 0.80 1];
y = [0 0.23 0.35 0.55 0.85 1];
outpict = imcurves(inpict,x,y); % spline interpolation by default
For an interactive adjustment, MIMT immodify() provides a graphical front-end for imlnc().

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by