steven_clark Posted November 6, 2003 Share Posted November 6, 2003 I don't know what to call it exactly, what I can think of would be a "histogram leveler" or to be more technical a "histogram integral map". Basicly this filter would be something that ensures that say the bottom 1% darkest pixels take up the bottom 1% of the contrast range and every other percentage slot contains the next 1% of pixels. The net effect would be the histogram coming out would be as close to perfectly level as possible. Has anyone ever seen such a filter implemented? If so what did the results look like? I could code it myself but I'd rather not build my own homebrew image-editor just yet. Link to comment Share on other sites More sharing options...
walt_donovan Posted November 6, 2003 Share Posted November 6, 2003 I don't think you'd get a creative "effect" from this kind of filtering, simply "shoving" pixels higher or lower to even the density count. I think it'd be unpredictable other than in obvious cases (noticable voids in the histogram, etc). Link to comment Share on other sites More sharing options...
jon_austin Posted November 6, 2003 Share Posted November 6, 2003 I can't imagine that you'd be pleased with the results from any photograph to which such a filter is applied. I think it's safe for me to state that the objective of photography is not to create an image with a perfect distribution of tones across the visible spectrum (flat histogram). Rather, the histogram is simply a tool for evaluating exposure, to avoid problems like under- or overexposure. Then again, maybe you would like the results, if you're going for some sort of abstract tonality effect... Link to comment Share on other sites More sharing options...
james_vornov1 Posted November 6, 2003 Share Posted November 6, 2003 I'd be curious to see what kind of algorithm you would use to do this. If you think about a picture it is an xy matrix of numbers, each of which corresponds to intensity. A historgram just shows how many of each number there is across all of the values. To equalize the histogram, you are changing the number of pixels with a given value. That means you have to change the value in pixels up or down to the value of number of pixels/number of values. If you think of a measuring the height of individuals in a population. You get a normal distribution of height. You have to pick individuals out of those with the most common heights and make them taller or shorter. Who do you pick? Which ones do you make taller? which ones do you make shorter? If you did this in a picture at random, you'd create noise in your image. Perhaps the method would be iterative, bumping pixels in the most populated values down to those of nearest neighbors to distriubute the values. Link to comment Share on other sites More sharing options...
steve_dunn2 Posted November 6, 2003 Share Posted November 6, 2003 <p>If your histogram has fewer steps than the image does (e.g. a 0-to-255 histogram of an image with 16 bits of depth), that would partly take care of the problem of which pixels from (say) the 120 column have to move up and which have to move down if 120 happens to be a spike; some of the 120 pixels would already be brighter than others when viewed at 16-bit depth, so you move the brighter ones up and the darker ones down. It would also keep the pixels that were towards the top of the 120 range from ending up at exactly the same brightness as the pixels that were towards the bottom of the 121 range, as there'd be enough depth to make them take slightly different values.</p> <p>I'd have to guess that the previous suggestion would be right - this would probably not yield a great image in a lot of cases. If you want to try it out, you could sort-of approximate it manually using curves and see if you like the results.</p> Link to comment Share on other sites More sharing options...
jwink3101 Posted November 6, 2003 Share Posted November 6, 2003 Does the historgram give you realitime results of what is happening before you hit apply? If it doesn't, it will be so much trial and error to get a flat histogram with the curves? Link to comment Share on other sites More sharing options...
emre Posted November 6, 2003 Share Posted November 6, 2003 In Photoshop: <b>Image > Adjust > Equalize</b> Link to comment Share on other sites More sharing options...
james_vornov1 Posted November 6, 2003 Share Posted November 6, 2003 In Photoshop, equalize seems to smooth by stretching or compressing across the range like you would do with curves. It doesn't make the histogram flat in most cases. But this is probably closest to the concept. Link to comment Share on other sites More sharing options...
andy_piper2 Posted November 7, 2003 Share Posted November 7, 2003 As Emre and James mention, the "Equalize" command comes about as close as you'll get. See attached. My question would be - Why do you want to do this? It would be like adjusting your stereo so that each note from every instrument came out at the same volume. Not what the composer intended. The things we photograph do not, for the most part, have equal distributions of light and dark areas. The fact that the histogram of a scan or digital picture is not 'flat' simply records this reality. It may be skewed to the left for a dark, moody picture; or skewed to thr right for a high-key, soft portrait. But it's not a problem with the histogram, it's just a natural measurement of what was in front of the camera. There is nothing 'good' about having an equal distribution of light, medium, amd dark pixels - and there is a lot 'bad' about it if it distorts the way the light was originally distributed.<div></div> Link to comment Share on other sites More sharing options...
steven_clark Posted November 7, 2003 Author Share Posted November 7, 2003 Mostly I was just curious. Also I'd think it might make a better starting point from which to tweak the curves, etc. As for an algorithm it's actually pretty simple:<br> <br> unsigned int histogram[MAX_UINT];<br> long i; for(i=0; i<=MAX_UINT; i++){<br> <tab>histogram=0;}<br> <br> for each pixel in the image<br> <tab>x = value of pixel in measured channel;<br> <tab>histogram[x]++;}<br> for(i = 1; i<=MAX_UINT; i++){<br> <tab>histogram = histogram + histogram[i-1];}<br> for(i = 1; i<=MAX_UINT; i++){<br> <tab>histogram = MAX_UINT * histogram / number of pixels in image;}<br> for every pixel in the image:<br> pixel.channelvalue = histogram[pixel.channelvalue];<br> Link to comment Share on other sites More sharing options...
emre Posted November 7, 2003 Share Posted November 7, 2003 You can use <i>FilterFactory</i>, which is one of the "goodies" that comes with Photoshop, to implement your algorithm. As for its usefulness...you could use it to create a contrast mask. Link to comment Share on other sites More sharing options...
andy_piper2 Posted November 8, 2003 Share Posted November 8, 2003 Steve: Fair enough as to your reason for asking. I do NOT think it would "make a better starting point....", however. Again I use an analogy - it would be like "adjusting" a van Gogh to make sure there were equal numbers of red, yellow and blue brush strokes. That's numerology - not art. If you just happen to photograph a scene in which there is a perfectly even distribution of tones/brightnesses within the frame to begin with, the digitized image may have a flat histogram. I guess a very well-lit studio shot with a crosslit gray paper background (natural 'graduated fill') might come close. For any other picture (i.e., about 99.99% of them) the natural distribution of tones will not be evenly divided, and the histogram should reflect that reality by being equally uneven and unflat. If you look at my previous example image - equalizing the tones to get a flat histogram created all kinds of distortions: noise in the seat cushion; a funky combination of flattened and increased contrast in the subject's hair; posterization almost everywhere (even done in 16-bit mode). Is that image really a 'better starting point' for adjusting curves, etc.? Link to comment Share on other sites More sharing options...
art_doyle Posted November 11, 2003 Share Posted November 11, 2003 Try this: http://dragon.larc.nasa.gov/retinex/ and this: http://www.truview.com/ Works great - sometimes. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now