View Full Version : Histogram and 'auto-levels'

10-29-2005, 09:48 AM
Hi everyone! Faced an interesting problem.

It's clear to me how get a histogram for an on-screen image. 2 questions:

1) How to get (compose?) a histogram for a floating-point image (texture)?

2) How to perform an 'auto-levels' (see <your favourite graphics editor>) operation on this fp-image (texture)?

Thanks in advance,


10-29-2005, 10:40 AM
1. Текстура с одним каналом - это и есть гисторамма. Для текстуры RGB гистораммой будет текстура с одним каналом, полученным как максимум соответстующих точек.

2. Найди максимальное число в гисторамме - М. Это число нужно поднять до максимально возможного в формате текстуры. Например, если М = 200, а макс. возм. = 255, то все каналы первоначальной текстуры умножай на (255 / 200).

З.Ы. Приятно встретить земляка на иноземном форуме, и диалог получился приватный :)

10-29-2005, 11:44 AM
well, that's what i call a clear answer to the problem.

but, may i add the following comment: if you solve your problem in the recommended way,
you should not forget to это и есть гисторамма, before you Найди максимальное число в гисторамме...

10-29-2005, 02:12 PM
Grand thanks to both of you! Признаюсь, поначалу был слегка шокирован языком ответа, нельзя так людей пугать :-)

10-31-2005, 12:55 AM
AFAIK, histogramm value is not max from RGB, it's the luminance value for given pixel...
float pix_lm = pixcol.r*0.2125f+pixcol.g*0.7154f+pixcol.b*0.0721f ;

10-31-2005, 03:15 AM
Calculating histograms for floating point images is a bit more complicated since there are an arbitrary number of color ranges in the image, but usually you just find the minimum and maximum and then subdivide this range into n buckets.

Auto levels in Photoshop essentially just scales the colors in an image so that the minimum value is mapped to 0 and the maximum to 255 for each channel.

It an attempt to make this relevant to OpenGL - there is an example of using occlusion query to calculate histograms in our SDK:
http://download.developer.nvidia.com/dev...gproc_histogram (http://download.developer.nvidia.com/developer/SDK/Individual_Samples/featured_samples.html#imgproc_histogram)

10-31-2005, 04:51 AM
и диалог пришел из приватного.как приватно как вы могл думать...не технология перевода чудесна?

возможно мы будем свободно языковойа барьер скоро.

наилучшия пожелания,

10-31-2005, 05:15 AM
Problem solved, thank you all!

And, as I see, language barrier is a problem no more too :-))

10-31-2005, 05:46 AM
As transfer technics is working than why not writing on rus layout... :)

Are coefficients may be other. There are many colorymetry government standarts in Russia at any rate are existing. But I am sure what this type of histogram is shall suit to declared intend.

Tom Nuydens
11-02-2005, 04:17 AM
May I point out that this is an international forum? Please post in English or don't post at all.

11-02-2005, 04:45 AM
Henceforth i shall look after keyboad layout. I'm sorry... :)