How to change contrast and brightness for one plane video stream?

Sep 13, 2011 at 11:21am

How to change contrast and brightness for one plane video stream?

Hey,

i try to change contrast and brightness for one plane video in jitter. I play with jit.op but I can’t find proper option. Do you know how to do that?

#58867
Sep 13, 2011 at 3:27pm

If you do mean “one plane video” then, as a start, with jit.op + or – (with a constant between 0. and 1.) should work to increase /decrease brightness. Another, second jit.op with op * may resolve the contrast once the brightness has been adjusted.

The “lazy” way is to pretend its a 4 plane movie (with jit.pack using the one source plane for each of the resulting ARGB planes) and then just use BRCOSA on that ; )

#211552
Sep 13, 2011 at 7:38pm

Brightness and contrast are explained briefly in Jitter Tutorial 7.

Brightness is just multiplication (not addition), so you could just use jit.op @op *. Contrast is a little more complicated and there are various ways to calculate it (Wikipedia that sh** if you want to know more), but the simplest and most common way is just to move all the values toward or away from the mean value.

Here’s a couple of examples of how you can do that with a 1-plane char matrix.

– Pasted Max Patch, click to expand. –
#211553
Sep 14, 2011 at 6:44am

Thank you so much guys :)
Christopher can you explain me why you use float32 matrix and later you convert it to char again?
thanks
wo

#211554
Sep 14, 2011 at 9:24am

“Brightness is just multiplication (not addition), so you could just use jit.op @op *.”

Not, at least, according to this: http://pippin.gimp.org/image_processing/chap_point.html

#211555
Sep 15, 2011 at 2:43am

@spectro

My statement was perhaps oversimplified, since the word “brightness” can be used in various ways.

One can talk about the brightness of a pixel, which for monochrome pixels just refers to where its value lies on a scale from 0 to 255, and for RGB color pixels usually refers to its luminance, calculated as (R*0.299)+(G*0.587)+(B*0.114).

One can talk about the brightness of an image, which can be calculated many ways but is probably most commonly and most simply calculated as the mean luminance of the pixels.

And one can talk about brightness as a “gain” factor that affects the value of each color of each pixel, which is the way it is used in the jit.brcosa object. In that object, the “brightness” attribute is a factor for simple multiplication (and it always multiplies the alpha channel times 1 to leave it unchanged). This page explains this use of the word brightness (as well as “gamma”) pretty well: http://www.bigshotcamera.org/sections/learn/proc/brightness.html

One can also use an additive offset instead of a multiplicative factor, as in the text you cited, and I think that’s how it’s used in many image processing programs such as Photoshop. I made the assumption that the OP wanted a suggestion for a way to affect the “brightness” of single-plane matrix that would be comparable to the way that jit.brcosa uses the term for 4-plane matrices.

In the context of Jitter, I personally prefer to think of “brightness 0″ as meaning “no brightness, total darkness” rather than “no change in brightness”.

#211556
Sep 15, 2011 at 3:03am

@ wojciechmorawski

I was assuming that you are starting with a char matrix.

The jit.op object does its calculations using the data type of the input matrix. The char data type has only 8 bits, which limits it to 256 values — a range of 0 to 255, or you can think of it in terms of a range from 0.000 to 0.996 with a precision of about 0.004. This limitation is a problem when a greater range or precision is needed for calculations.

Here’s a patch that I think illustrates the difference.

– Pasted Max Patch, click to expand. –
#211557
Sep 15, 2011 at 2:14pm

Thanks very much for that detailed and considered response Chris. It’s certainly helped to clarify some of the confusion regarding the use of this term for me. Cheers.

#211558
Sep 26, 2011 at 1:53pm

Thanks Christopher
you’ve helped me a lot
:)

#211559

You must be logged in to reply to this topic.