View Single Post
Old 11th November 2010, 22:56   #60  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
The original code when used with RGB24 was almost doing the right thing (just wrong limits). In RGB each colour channel can range from 0 to 255. The colour depicted is related to the ratio of the R, G and B channels. This ratio must be maintained. You should just be looking for the Maximum and Minimum values of any channel and then scaling and biasing all RGB channels equally, the A channel should be ignored.

Like most filters that fiddle with brightness and contrast in YUV colour space we cheat and only process the Luma channel. The 2 chroma channels are not adjusted. The hue of the colour is related to the ratio of the U and V chroma channels. The saturation of the colour is related to the ratio of the U and V channels to the Luma channel. The luma only cheat may lead to noticable changes in saturation when the adjustment is not small.

Expect different results when processing RGB compared to YUV. The RGB results can be strictly correct, the YUV results will be a compromise. You can see the effect easily in VirtualDub with the inbuilt Levels filter by toggling the "Operate in luma instead of RGB" option.

And all YUV results should be the same. YV12 and YUY2 being different is a bug.
IanB is offline   Reply With Quote