![]() |
Histogram linear vs. non-linear - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Histogram linear vs. non-linear (/Thread-Histogram-linear-vs-non-linear) |
Histogram linear vs. non-linear - Merlin - 05-22-2025 When working with Gimp's histograms, you always have the choice of whether you want to display the x-axis linearly or non-linearly. When working with python the function to get the histogram values has no paramter for the x-axis e.g. t, mean, std_dev, median, pixels, counter, percentile = layer.histogram(Gimp.HistogramChannel.VALUE, 0.5, 0.6) returns the values using the non-linear x-axis. In contrast the function to change the histogram e.g. t = layer1.curves_spline(Gimp.HistogramChannel.VALUE, curve) calculates the spline on the linear x-axis. I found this out by comparing the values with the manually created values in Gimp. I need a possibility to gett the correction by spline on the non-linear x-axis. Is there a way to achieve this? RE: Histogram linear vs. non-linear - Ofnuts - 05-23-2025 I published functions to go from linear to gamma-corrected and vice-versa here: What is the gamma encoding and why are my color computations wrong? RE: Histogram linear vs. non-linear - Merlin - 05-23-2025 (Today, 07:03 AM)Ofnuts Wrote: I published functions to go from linear to gamma-corrected and vice-versa here: What is the gamma encoding and why are my color computations wrong? Thank you for your reply and the link. I understand that it is much better to do the calculation in the linear system, but, sorry, my mind and eyes work with the gamma corrected system. What I'm trying to do is analyze the histogram and do a little automatic value correction. So I take the values from the histogram function that are in the gamma corrected system. Now, let's say I decide to increase the brightness a little bit with a spline like this: curve = [0.0, 0.0, 0.75, 0.875, 1.0, 1.0] in the gamma-corrected system. The calculation of the curves_spline function with this curve leads to a completely different result, as the function calculates the spline in the linear system. Due to the non-linearity of the conversion, it is not possible to simply convert the 0.75 in the spline definition to get the correct result. In the upper row you can see the histogram with the correction spline on the leftside and original an result histogram on the right. In the lower row the same with the spline calculated in the linear system with the different result. Is there a way to get the result of the upper row by converting the spline definition or any other function? [attachment=13506] |