Changing the brightness of an object

Post questions on how to use or achieve an effect in Inkscape.
Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Changing the brightness of an object

Postby Ailurus » Tue Nov 20, 2012 2:34 am

Hi,

I'm looking for a way to change the brightness of an object, preferably by a certain percentage (i.e. increasing the brightness by 40%, effectively making it 40% lighter).

Changing the opacity of the object almost does the trick, but it has an obvious drawback: if there are any other objects behind it, they will become visible.

Any other approaches to get this done? The extensions and filters don't seem very customizable. Perhaps a mask, but how? Another (rather ugly) solution is to create a white rectangle on top of the object and change the opacity of this rectangle.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Changing the brightness of an object

Postby druban » Tue Nov 20, 2012 8:00 am

I am intrigued, Ailurus, because you seem to be a proficient - dare I say power - user :) so you must be asking something other than what i am hearing.
Is it a single object? Or is your request largely the same as this one.
If it is a single object, is it a vector object?
And using the HSL option and adjustung the lightness slider is not how you want to do this?
If it's not wanting to open the dialog, the gestural controls from the fill and stroke swatches seem to be quite stable now. Ctrl-drag fro lightness adjustment.
Your mind is what you think it is.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Changing the brightness of an object

Postby v1nce » Tue Nov 20, 2012 8:33 am

create a new filter.
add a composite fx. set operator to arithmetic. set k2 to 1 + brightness boost (1.4 for a 40% boost for exemple).
apply.

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Changing the brightness of an object

Postby Ailurus » Tue Nov 20, 2012 8:53 am

Hi Druban, thanks for your answer and the compliment :D. Actually, there are multiple vector objects that I'd like to change at once. By simplifying my question I completely forgot about the HSL sliders... But unfortunately, they (the sliders) are not there when the objects have different styles.

If I would have a little more time, I'd just write a script to fix the problem, but this seems like a pretty standard thing (so it's either already available in Inkscape or on a wishlist). In the topic you linked there seems to be some confusion about the application (whether the graphic is bitmap/raster or vector), but the linked request on launchpad sounds more or less like the functionality I'm looking for.

Addition: Thanks v1nce for your input. To be honest, I don't have any experience creating filters. The 1.4 factor seems a little too much, but 1.2 is about right. However, this only changes the fill, not the stroke. What should I add to this filter in order to change the stroke as well? Any good references for creating filters?

Edit: Connecting Input 1 (i1) to "Fill Paint" and Input 2 (i2) to "Stroke Paint" doesn't seem to work. I'll read Tavmjong's overview of filter creation at a later time in more detail.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Changing the brightness of an object

Postby v1nce » Wed Nov 21, 2012 4:45 am

> Connecting Input 1 (i1) to "Fill Paint" and Input 2 (i2) to "Stroke Paint" doesn't seem to work

AFAIK fill and stroke don't work in inkscape for now (anyway their use as defined in svg spec is pretty stupid imho)

You don't have to link to those input. Simply add a composite. It will link to source image (that is what you want)

See attached image. The original shape is at the top ; at the bottom same shape with filter applied (you should see that the 'brightness' is applied both on stroke and fill)

Image

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Changing the brightness of an object

Postby Ailurus » Wed Nov 21, 2012 9:42 am

Ah, the reason why it didn't work is actually quite simple: I tested it on a path with a grey fill and a black stroke. Black is read as value 0, so it isn't affected by multiplication (K2). It is however affected by addition (K4).

Note that multiplication is relative: multiplying it by a factor changes the brightness in a relative fashion. Something already bright becomes relatively brighter than something less bright. Addition is absolute, in the sense that every color is affected in the same way.

In order to brighten black objects, K4 should be something positive (e.g. 0.20). However, to prevent other colors from brightening too much, K2 should now be less than 1.00.

After all, I guess that my initial solution (placing a white rectangle on top of the objects and changing its opacity) is the easiest and quickest. But any other solutions are still welcome!

chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Changing the brightness of an object

Postby chriswww » Wed Nov 21, 2012 9:56 am

Adjusting perceptible brightness or even hue is much more of an art than a simple linear scale.

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Changing the brightness of an object

Postby v1nce » Wed Nov 21, 2012 10:26 am

> Adjusting perceptible brightness or even hue is much more of an art than a simple linear scale.

agree :)

any volunteer for turning rgb => hsv => rgb algorithm into a nice filter ?
it should not take more than 30 stages :)

a starter : http://www.javascripter.net/faq/rgb2hsv.htm

Ailurus
Posts: 115
Joined: Fri Oct 22, 2010 9:53 am
Location: The Netherlands
Contact:

Re: Changing the brightness of an object

Postby Ailurus » Wed Nov 21, 2012 10:08 pm

v1nce wrote:any volunteer for turning rgb => hsv => rgb algorithm into a nice filter ?
it should not take more than 30 stages :)


Actually, in the extension I wrote for the L-system plugin, there is some part that takes an RGB color, converts it to HSL (not HSV), changes the Lightness, and converts it back to RGB. Might be useful :)

Link: viewtopic.php?f=34&t=12476&p=46966#p46966

chriswww
Posts: 383
Joined: Fri Nov 19, 2010 3:04 pm

Re: Changing the brightness of an object

Postby chriswww » Thu Nov 22, 2012 10:01 am

i'm sure it's good code...but what i was referring to is that generally colors and brightness are all relative to other colors on the screen. I recently viewed a video on youtube by Sycra which explains color selection using the triangle color picker. It's not about inkscape but pertinent reminder about color perception. On top of that if you consider the user intent for effect desired on the different layers of objects, which can be over simplisticly stated as hue or lightness shift, the linear [or exponential] scale sliders of any kind cannot hope to automate the process. Hence there's a lot of "art" in adjusting colors etc by hand. A good HSV color picker doesn't go astray though.
Anyway, apart from my straying rants, what's the point of a rgb => hsv => rgb filter? Maybe it is time I had a look at writing something for inkscape...if i clearly understand the intention.


Return to “Help with using Inkscape”