Forums > MaxMSP

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

Sep 13 2011 | 11:21 am

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?

Sep 13 2011 | 3:27 pm

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 ; )

Sep 13 2011 | 7:38 pm

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. --

```
```
Sep 14 2011 | 6:44 am

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

Sep 14 2011 | 9:24 am

"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

Sep 15 2011 | 2:43 am

@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".

Sep 15 2011 | 3:03 am

@ 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. --

```
```
Sep 15 2011 | 2:14 pm

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.

Sep 26 2011 | 1:53 pm

Thanks Christopher
you’ve helped me a lot
:)

Viewing 9 posts - 1 through 9 (of 9 total)

Forums > MaxMSP