increase luminance of a matrix
I’m trying to create a jitter effect (using jit.op or some other object through which I can pass an existing matrix) where each pixel has its luminance increased, as if the H portion of the HSL notation had been increased.
So for example, if luminance runs from 0.0 to 1.0, and we fed in a parameter of 0.3, then the luminance value of each pixel increases by 0.3. Thus, pure red would become pink, muddy yellow would become a brighter yellow, etc. Luminance would be capped at 0.1, so any pixel that was already close to full luminance would just look white.
I’ve attached a screenshot to make my intentions clear.
I tried jit.brcosa (using the @brightness attribute), but this does not raise a pixel above it’s original luminance – it can only reduce it.
I have a hunch that I will need to convert each pixel value to HSL, increase the L portion, then convert back to RGB. I have the required formulas from http://easyrgb.com/index.php?X=MATH – but I’m not sure how I would use them in Max. Is this a job for Gen perhaps?
jit.rgb2hsl and it’s @lscale attribute
So simple! Thanks!
Here’s a demo. I used jit.rgb2hsl as advised, and then jit.hsl2rgb to convert it back.
----------begin_max5_patcher---------- 972.3oc0XsrbaBCEcs8WgFFuzwCR7zcU62QmNYjAYakADTgvwtYx+d0CvEmX ZTc.R5hDF8.y4d3bO2K5o4yb1TbjT4.9B36fYydZ9rY5oTSLqY7Lmb7wjLbk daN4jpJ7NhyRyZBxQgd90P.JH.DCaWgUmWTKxHB88Aalklp2cwlGtCgZ251B lfgyI5k9Fmhy5tRE8W5UfnUtMSWhEI6orc2yIIBC58hCjKCPPW0EHxbIdkK3 GM2jAMhSkDyc33bdIIVorVnhTy8774p+s7cxJPuPMs.QgVyKv0CIu.c8ULQ. Zs5Rb7jRKIE44Dl3Uzh7YVVK.UXQMGKnELv1r5DQMVPpVBJ4EavaxNARqI.Q APrm.dDeBT8nJ7.TlfvK4RXAvL4H4CQFx.9tMfC3rZxp1GWFkQRJpY5moWKy I2mZr6YR6xWHtW4Eh+fJT8TKChLBUju90ieTm2HWP6vaf1YjGk39UrdVANUI Tkwt0hwvgLz8cMwbfmlALIrt2fV7VHkpLZJgaeVX6NaCMahLOTS.pS1PdcBs RLWxdRk68DlTbS5p09Kg8V4KMgIcoKPujMZlTNkZ3cvUtCXtZxdLaGAje1b6 FxfPtCpLZs+p.IYa37H2WIid2Zk9ryQAH6EPwCYLGDE1w0H3yQ0sEHvBOvBe 64jfAszVj1Gw2TTKHZR4jd7XefJVQE84y3cEJwaLnDi.wOzBG1kM+MfNs55z WmAPWgANmSIsfjwDcCMiJN0UB0eYzl9ZPQ5QPU0zazxUxAZy1dHBugUiruJC o7QsljfigLAouDhdaYhDy2miEb5wAVrzm2REQfyxzMOu.BzNM1ayLnkaPAPM +XnIHDMo9L+iISw2TtjIzZrK9eJUR0R6FY+IVKMFzBPdsRBcVj6amEog5n2m uxeoMW0RYi+H3t3A0WBB9.cW5gg9oTKyKjfB7Ubhfdf.r+XKFz50QwlCsXs4 PKfuKIz.2Fir7DRVlxZMDZLzPFB5CsBEVH30T6K9b9SlU2XiK01sx5YivmR6 0bfNAtCx2Rq2g9bSdwYBpQfZ9K4ophZdR6ueS4GvefPJoRPY5C3oydTm6G.d dS6oooDV2BJozJUMFMkd8uj0V3n9di2DOpyaahvSnMv4h8LpriMnIbxfiMZG UmcSDbrQ5DOYnw2lDqICMdVfF+ICMHaDNSXZU3mp2U14ANg3wFwyK.8nhmKK G0CdhmtZVVYK6Mc7i6HlraZ3.WVdfvqZ9I0HQ1B1CE5tmBWN2b11lg5Ntb3j Cz18qOTMGLW1hjP1eTM2zX0w3Pm4pmyyy+80pcZc -----------end_max5_patcher-----------
unfortunately 2hsl and 2hsv are the only ones which i did not got right from looking at the quasi codes found on the web, when i tried to do them all recently.
the picture below shows how it would look like (if the last bug in it would be corrected finally – i somehow lost interest in it)
btw, not sure how important it is for your project, but the L in HSL stands for lightness, and not for luminance. ;)
for luminance, which you were asking for, you would need ALL of the three abstractions i posted in this thread http://cycling74.com/forums/topic/rgb2xyz/
quite a bunch of code for something so simple.
no, wait, thats luma, not luminance, my bad.
it is always a bit hard to keep the difference between lightness, brightness, luminance, and luma in mind if you´re not native english. ;)
luminance or lightness can be found in L*a*b.
Forums > Jitter