It is currently Tue Jul 23, 2024 6:16 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 7:25 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
I was googling in search of some filter for Gimp being able to fill the gaps in the histogram which are created when using Colors>Levels adjustments.
I didn't find one (maybe, there is...).
But surfing, I encountered a link which advertises this capability in Power Retouche filters
see PR histogram repair.
Does anybody know whether there is something similar for Gimp?
btw, PR plug-ins are not free...

_________________
"Where am I ?"


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 8:37 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
Mathematically you can't.... Each color is represented by a set of 256 values. All the color adjustments (levels, brightness/contrast, saturation, curves...) just map the 256 possible input values to some other values. But there is a rather strong constraint: unless you want special effects (solarization) the possible output values should have the same order as those of the input: if in the input V1 is higher than V2, then in the output the corrected V1 should be higher than the corrected V2 (in the Curves tool this means the curve never has a top-left->bottom-right slope). And this implies means that you cannot use the 256 possible output values(*), you will always end up with less values. In 16-bit processing (on a 16-bit image) this also happens but is much less visible because the gaps are much lire likely to be below our perception (and fewer pixels are impacted). And of course, if you cumulate color corrections the problem worsens...

But can it be "corrected"? The only thing you can do is locate the gaps, locate pixels with values around the gaps, and randomly alter these values so that some pixels get a value in the gap. So, your histogram looks better, but is the image better?

Also, do this quick test: in the page your refer to, get the two 8-bit pictures of the guy, before and after histogram fixing. Load them in Gimp. Check their histograms. Gaps? Peaks? None whatsoever in both pictures... Strange? Not really. When you scale down, the pixel interpolation generates intermediate values and this evens out the histogram.

Personally, I don't use Gimp for color corrections, I use 16-bit capable software and when possible I work from the raw photo (theoretically 14-bit, on practice more like 10-12 but still better than 8 for this). And if I have to start with an 8-bit image (JPEG) I try to do everything in one single correction.

(*) assume the middle of the range (127) is mapped to something bigger (150). In the low range, values 0-127 in the input get all mapped to values in 0-150 (there will be 23 unused values). In the high range, values 128->255 (128 values) are mapped over output values 151-255 (105 values) so some of the input values end up mapped to the same output value. Hence you create gaps at one end, and over-used values at the other. This is the origin of the "haircomb histogram".

_________________
Image


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 9:01 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14728
Location: USA
Have you tried using GIMP-2.9? I haven't but it may be a better result as it handles more than 8 bit.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 9:30 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
@Ofnuts
thanks for your detailed explanations. Now come my "stupid" questions: (I'm not a mathematician, so many of my questions could be "stupid"):
- assume the levels are adjusted such that they are just reduced 1:2 (for simplicity), so resulting values between 0 and 127 become values between 0 and 254, with "gaps" inbetween (0-2-4-6-....with values; 1-3-5-7...with no values); now:
1-how are the values "modified"?
2-why is it mathematically impossible to generate values inbetween? applying some kind of a smoothing mechanism like (for instance): there are 50 original pixels with values of 1 which should become values of 2, couldn't be a solution to keep 25 pixels at 1 and moving 25 pixels to 2? (on a specific request of the user, of course, because the resulting image looks a bit different )

@Rod
thanks, not yet, I didn't try it; but what you are saying is that in 2.9 even images 8-bits based are processed as if they were 16-bits based?

_________________
"Where am I ?"


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 9:59 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14728
Location: USA
dinasset wrote:
@Rod
thanks, not yet, I didn't try it; but what you are saying is that in 2.9 even images 8-bits based are processed as if they were 16-bits based?


I do not know. As i stated i never used it before. :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 10:43 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
it seems that version 2.9 is -at the moment at least- only for 64-bits systems

_________________
"Where am I ?"


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 11:50 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
good news by googling:
found a FREE PS plugin compatible with Gimp-PSPI which performs what I was looking for:
ThePluginSite - Photo Freebies - Histo Fix:
the description says: "It fixes a chopped histogram by interpolating lost image information. You can regain 1/2 bit, 1 bit or 2 bit of image information. Works only on 8bit images, because 16bit images do not have this problem."
Tested, no bad effects on the image, gaps filled

_________________
"Where am I ?"


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 12:24 pm  (#8) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
dinasset wrote:
@Ofnuts
thanks for your detailed explanations. Now come my "stupid" questions: (I'm not a mathematician, so many of my questions could be "stupid"):
- assume the levels are adjusted such that they are just reduced 1:2 (for simplicity), so resulting values between 0 and 127 become values between 0 and 254, with "gaps" inbetween (0-2-4-6-....with values; 1-3-5-7...with no values); now:
1-how are the values "modified"?
2-why is it mathematically impossible to generate values inbetween? applying some kind of a smoothing mechanism like (for instance): there are 50 original pixels with values of 1 which should become values of 2, couldn't be a solution to keep 25 pixels at 1 and moving 25 pixels to 2? (on a specific request of the user, of course, because the resulting image looks a bit different )

@Rod
thanks, not yet, I didn't try it; but what you are saying is that in 2.9 even images 8-bits based are processed as if they were 16-bits based?

1) I don't understand the question :)

2) Because information is lost... the plugin just adds noise... Assume your image initially had better precision (12-14bits), so you can add some decimal places to the 1-255 values. The values that are at 120 in the 8-bit image would range from 119.5 to 120.5 in the original image. Now you apply some processing that stretches the values, so that 119 is converted to 128, 120 to 130 and 121 to 132. The gaps will be filled by taking some pixels with value 130 and assigning them values 129 or 131. But value 130 comes value 120 which itself represents the 119.5-120.5 range in the original image. So you can fill the gap at 131 with values that could originally be 120.5 (fine) but also with values that were 119.5 and would be much more accurately represented by 129 (ouch). And, of course, vice-versa.

To answer for Rod, in 2.9 when you process 8-bit images in 16-bit, you also initially start with 256 distinct values, but the problem is much less, because even if you create gaps, you don't lose colors. To use the example in the footnote my first post, in the high range your image starts with 128 distinct values, but you can map them anywhere in 26880 values instead of 105, so they remain distinct...

_________________
Image


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 12:26 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4757
dinasset wrote:
good news by googling:
found a FREE PS plugin compatible with Gimp-PSPI which performs what I was looking for:
ThePluginSite - Photo Freebies - Histo Fix:
the description says: "It fixes a chopped histogram by interpolating lost image information. You can regain 1/2 bit, 1 bit or 2 bit of image information. Works only on 8bit images, because 16bit images do not have this problem."
Tested, no bad effects on the image, gaps filled


Advertisement lies... you don't regain information.

OK, you filled the gaps, so what?

_________________
Image


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 12:47 pm  (#10) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2446
Photo Freebies: They are actually, not bad, little .8bf PS filters, once you have jumped through hoops giving a throw-away email addy to download them.

Even work with my linux pspi - and not many do these days.

I can see Ofnuts argument about regaining data that is not there in the first place.

but

Why not try delaboratory for some preprocessing, the compiled win versions are on Partha's site or here

http://code.google.com/p/delaboratory/

Compiles easily in linux. Worth a try.

_________________
Image


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 12:55 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
@Ofnuts
I understand: what is lost is lost. And certainly it's better not to have lost too much.
Simply, I don't like the gaps...
And -as per your example- I don't feel too much uncomfortable with a 131 value which can come from a value half-a-bit lower or half-a-bit higher
Thanks again for your help
(btw, you answered also my first question: how the values are moved...)

_________________
"Where am I ?"


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 1:36 pm  (#12) 
Offline
GimpChat Member

Joined: Jan 20, 2014
Posts: 66
Would Gaussian blur with radius of 1 can help? Random mapping gives you noise, as it is not influenced by it's neighbor pixels.


Top
 Post subject: Re: filling value gaps created by levels adjustments
PostPosted: Sun Feb 02, 2014 2:31 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
@oky
I didn't see any noise in my trials with histo fix;
maybe that plug-in is more clever than we suspect and takes into account not only the "value" in general but also each single R,G,B value, so to interpolate between similar tones, not "randomly"
I don't know...
Yes, Gaussian blur can do its job, but it's certainly a ...blurring mechanism; I don't think that -for example- when upscaling an image the "new" pixels are creating by a simple blurring mechanism.
Again, I'm not so expert to understand the underlying mechanisms, I just look at the results.

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Smooth transition of textures over gaps. (its hard to explain)

7

No new posts Attachment(s) Plays with Filling

27

No new posts Attachment(s) Diego's Filling scripts (tutorial at post #33)

32

No new posts Gimp filling the canvas not stroking the path - RESOLVED

7

No new posts Attachment(s) How to reproduce Gimp's levels using blend modes of color fills

0



* Login  



Powered by phpBB3 © phpBB Group