How to change contrast and brightness for one plane video stream?
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?
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 ; )
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1013.3ocyZtsbaBCDF9Z6mBM9pllDWzI.2qReNx3oC1ljnNfvCHOwsc56d0I ensNIqkohjYLdjP.+5aWs6hb943QSVzrsraB5yn6QiF8ywiFY6xzwHe6QSpK 1trpnyNrIxxmaV7sI23Nkpbqx1cUSwp5xtNDd5tyI2T2rQUUprWH12qXkc75 6wsL9tg9PiTIKpKsm5KshhpcmwcGTeecoSjSlflezE0I9g8DXxzDe2qKTKeR He7qskKUtKhSx0mFgSMGy3lijjoI6uSZkJj6EpoueMdr4vM.gxxl55Ro5enx ChpJTSq3QgrnBUWnZEaOMdRNAdXuMdfy.p4rHlCDIIwiAAO8I84zmvsFercT n7H5C7AYSacQU02QKJUOWVJQInB4JD9JvnfNqOQAOK8HWAGWhCJVp0XaQmB9 DOqOm3r7jCSbNs+m2uPrwOo893vCKRCIr3C5.vpPhMlmxLffxcwGvuNUH8GU 9lPMkVeZpvNAUXgjr3li9DBbb9JTW9iT9TdjbYLvwEuDgQKepnEwPzSyJxIX EI.VoejecWH5vnEgYWeg8YacgZ6WbY3x5mExUMOCmF3W2+Xu5NwTJi5hU5RX 5hejFKGfxsqaQ2Ijq2n5PTzc11B4834WqORl+wOn+JY9s1ttBNORFDuCOJot rOjL1q6cPeurXhjOH3hgOFW+WVLAAW17JTx4QL1PRLh6KLgGMhoPKPO.GOgD cdQg7QCXBNOu+cfxr9QTZ+mIKjPy3YgGZ1atGlPyMqQ2o+bM7Y5vFEwUc2r7 nVcmGReDNjxFTH4qagkNDT5V3TJcPoThMwcN885KJf4CvKJvbuEEwEdMM8cR 30Knx2cEymF6vqlcRzksC36KOKzzoAXm8kXv1Qi91JuXiR0HAO0yANAewYBa eFg9dlnKTQeO.6plF7ddbS3VSeMQ9MDJIpUXKaDckA89HCRze+dmSbaebNbT YGwjJg7u+YFrODS++I+5Z1ztbmt893nCOmUkcJgrPIzqRNLFxeLlmDqVUJOd KEqEqV2HjJuDPyOosDphlAPQ4QUQlRBdSIYptJlZJChlhKmffIRbclrONLDS GFtl3958sKZMM3tFWpVYPLo7yieLhaaUca8LKituUTTaZbWTvgXsSOOqcTzT 94oIV9roT8eLl1X58C0u4.225RkLnjBwM1BAhlvyhplLa06apIy9iGSMQfX6 XmmlHrYFeKr6W0yGRw1JFpEiCVs1XcGZco9fPL2mY9MOK0U6cjVMshAY+KG3 yzOHi0a9Aj+GnkSy7YlOfVSiKkrL.Azo73tpmC0ZieeU5kUSjPJ8ha+GsIou Lpfb.unvl47r9Z4BCh49RJ8R23Wi+MD7siaB -----------end_max5_patcher-----------
Thank you so much guys :)
Christopher can you explain me why you use float32 matrix and later you convert it to char again?
"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
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".
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. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1194.3oc0assbaaCD8YouBN5wVGObwUx9T52QmLYnkXhQFdQiDUqayj+8RB. 5HmXEuff.T5AKJRBAt6A6d1Kf9qqWs4g1mJOtI4OR9qjUq955UqzWZ3Bqrmu ZScwSaqJNpG1lss00kMcatybutxm5LW+whCIGJOdp5460bpt8TWUYm9WlZup Zmd7sO7k2I3iC8SsMcME0k5a8mGTEUi2Ye+b1+7J5TsMe7P41NivJIj6SuKg vSGNL9QxGNa9Np9O87ACizNYEcaeT074WLQ5eLgkMbPH0mb9T0qEplQk.Ft1 2Vud3i6PhXeppseNdcPg7JfB8sAEyLz8u6KMJwvynnG2S17PQym27rreAvSH EFcV5I3Ijjy.OyZw7BdMk+SOn7SVaeQ0c+w8ppJ7vJaBv5.hhFMIzYBMIrgC LZTQy5htCpmRfDsiLfGWIS.W6efez7.wgvhLCV.yDBmpmCHkL+P7k3GsdnHY F4x2FUwq17rzyLrnz3o0SIp.mOm5NKWbltGB98e4JdhpY+IGzc5bp6BiRaL5 EwdY2QMGl0UcggCM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detailed and considered response Chris. It’s certainly helped to clarify some of the confusion regarding the use of this term for me. Cheers.
you’ve helped me a lot
Forums > MaxMSP