GNOME Bugzilla – Bug 72951
Option to choose between linear and logarithmic histograms and add luminosity channel
Last modified: 2003-10-24 08:23:22 UTC
I'v noticed such a problem with Image/Histogram function. The values like: Mean, Median etc are ok, but the relative height of the histogram bars are not correct. Maybe it is not a big problem, but photoshop's bars are proportional to each other ;-). To be clear. Make an image with 1/4 of white and 3/4 of black. So having 100 pixels total we have 15 white and 75 black. On histogram everything is counted right, but doesn't look right. The white bar should be 1/4 the height of the black one. Now I know that in gimp they are logarithmic, maybe not a big problem but I'd like to have the choice to switch to linear/logarithmic histogram. The second thing is about making histograms from part (selection) of an image. Why can't I do this? Even when I make selection the histogram is still based on entire image. Strange because histogram in Levels' window is selection sensitive. For photos it would be usefull to select only main subject and analyse only his own histogram.
There are two separate enhancements in your bug report: one is about the linear/logarithmic option, and the other one is related to the selection. It is much better to have one report for each bug or feature, so that we can track them separately. So I propose that we keep this bug report only for the first part (choice of scale in the histogram). Please re-submit the second part (selection) in a new bug report.
Sven mentioned on gimp-developer wanting a volunteer for this, so I thought I'd take a stab at it -- see patch (against yesterday's cvs tip). I made the UI just a single checkbutton. It could also be two radiobuttons, or something else -- let me know if it needs to change. The rest is fairly straightforward.
Created attachment 13817 [details] [review] Patch: allow toggling between logarithmic and linear
Thanks for the patch. I will commit a change based on your patch to CVS as soon as I've figured out a few remaining issues.
I've implemented this (based on the patch) some time ago: 2003-01-25 Sven Neumann <sven@gimp.org> * app/widgets/widgets-enums.h: added a new enum to specify how to display histograms. * app/widgets/widgets-enums.c: regenerated. * app/widgets/gimphistogramview.[ch]: added a scale property and made channel a property. Added support for linear histograms based on a patch from Akkana (see bug #72951). * app/widgets/gimphistogrambox.c: redraw the gradient when the histogram view notifies it that the displayed channel has changed. * app/tools/gimphistogramtool.c: added a menu to configure the histogram scale. The bug-report is still open since I believe that the levels dialog should probably have the same option. Apart from that, the user interface needs some fiddling since the option menu takes quite a lot of space. We could make this a right-click menu (but that would be rather hard to find) or try to come up with some nice icons and replace the enum-menu with a (much smaller) enum-stock-box.
'The bug-report is still open since I believe that the levels dialog should probably have the same option' First of all it should be done for Levels. Maybe you could try to see how it is done in Color correction plugin? As I understand you want this option to be in Levels (or histogram) window? I think it it not necessary. IMHO switching between linear or log should be done in Preferences. I really don't need to use log histograms when have linear ones (especially switching on the fly).
The choice has already been integrated into the Histogram window some time ago. You could at least look at the current version sometimes. What "color correction plug-in" are you talking about? I guess there exist several dozens of those. Perhaps you could provide a screenshot. The surprising thing is, given the possibility to switch between logarithmic and linear scale on-the-fly it becomes apparent that the logarithmic view is a lot superiour and I can hardly imagine that someone would want to work with the linear scale. There are some rare circumstances where linear scale makes sense and this seems to imply that the switch should not be moved to the preferences dialog.
As a photographer I see some problems using LOG Histogram. Good example shows situation when user wants set White/Black Points. Just look on this screenshot: http://tme.szczecin.pl/~jacek/temp/Graphs/gimp_ps_hist.jpg On GIMP's Histogram the data are clipped and on Photoshop's not! The white being on ~245 is not shown proper in GIMP. The image: http://www.cix.co.uk/~tsphoto/tech/filmscan/howtek/howtkq60.jpg Regards -- Jack
The difference that this example points out is not the different scale. The photoshop histogram shows luminosity while the gimp histogram displays value. Changing the scale from logarithmic to linear will not give you the desired result.
As far as I know the simplest Luminosity is calculated using linear scale factors: L = 0.299*R + 0.587*G + 0.114*B Then if you switch to RGB channels separately you see the same situation - very small noise in LOG scale histogram tend to smear valuable data. In other words it changes nothing and we looking on pixel count here! BTW: I really like ImageJ and some features for serious photographers: http://tme.szczecin.pl/~jacek/temp/Graphs/gimp_ps_hist2.jpg Cheers -- JZ.
I am aware how luminosity is usually calculated but there is no way to get a histogram showing these values in GIMP. Please open a new bug-report if you think that it makes sense to add this as another histogram channel. At the moment we only allow to display pixel value which is calculated as the maximum of the RGB channels.
I can only add that rest of the world use Luminosity and that's great. If you compute max from RGB channels then your remark: "Changing the scale from logarithmic to linear will not give you the desired result" Is unsuitable. Specially I showed example with grayscale with equal pixel value. The Histogram tool should display in the same time two: linear and LOG histogram. I have no idea why you did this contrary to the rest. All free software have Linear/Luminosity histogram or with LOG option. I wish you just enjoy the pursuit ;) JZ.
Sven, have a look at this url: http://www.mail-archive.com/gimp-developer@lists.xcf.berkeley.edu/msg03432.html This is what we (photographers) need. The jpg file in that letter shows clearly the difference between log and linear histogram. Can you set White point/Black point using log histogram (http://www.marso.com/images/example.jpg)? I doubt. And I was talking about color corection plugin mentioned in this letter above. Piotr
The JPEG file clearly shows that the main difference between the two histograms is not linear vs. logarithmic scale but actually what values are displayed. As I said, please open a new bug-report that deals with this. I think I like the idea of displaying logarithmic and linear histogram at the same time. We should consider this.
Can we take some calculations? If you pick up colour using 5x5 average from foliage and wood you get: Foliage == 206:164:128 Wood == 118:151:67 This subject make up 85% of an image. So the "value" used in GIMP is a max value == code 206 and 151. Then the *delta* of this two is Dv = 55 or 0,21% in normalized range. If you compute Luminosity using Rec. 709/PAL/NTSC for nonlinear data (R'G'B') you get: Foliage => Lf = 132 Wood => Lw = 173 So in this case the delta Dl = 41 - a little smaller then in GIMP value calculation. So what happend if we take LOG scale? In normalized range [0,1]: LOG(Lf) = 0,93 LOG(Lw) = 0,88 Delta_log = 0,05% So if I understand the log scale of LOG histogram right then the delta of LOG histogram is too small and you have this into the image. Look! This main peaks are just invisible. So what you mean that LOG is helpful? In some images surely yes (e.g. in HDR imaging) but that's why LOG was used in the past and now all community using linear with log option for regular users... Regards -- JZ.
There is really no need to argue, linear scale is already implemented. It will definitely makes its way into the levels tool dialog as well. Look, this report has milestone set to 1.3.x. This means that the feature is schedulded to be implemented in this development cycle.
Ok, I see. So the last thing woulde be another bug report for the Luminosity calculations because every strong primary colour in image will be boosted by value histogram - e.g. flower in that JPEG. JZ.
Removing the PATCH keyword since the patch has been applied and there's no patch for the remaining issues.
Changing summary appropriately to the remaining problems. It would be also nice to reconsider the simultaneous display of the linear (black) and logarthmic (gray) histograms as on this screenshot: http://tme.szczecin.pl/~jacek/temp/Graphs/gimp_ps_hist2.jpg to unclutter the ui.
Bumping a bunch of enhancement requests which will not be done by the feature freeze to Future. Dave.
There is another bug report for the Luminance channel (bug #109161). The linear scale is now available optionally in all histograms. Closing this report as duplicate of the report with the respective CVS logs. *** This bug has been marked as a duplicate of 125306 ***