Light a region matching colors

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
agoyen
Posts: 4
Joined: 2016-02-13T14:39:43-07:00
Authentication code: 1151

Light a region matching colors

Post by agoyen »

Hi!,

Is there any way to make a region lighten?, but with fuzz/opaque results included.

Example:

Code: Select all

convert input.jpg -region 73x31+45+36 -fuzz 8% -fill red -opaque '#a9afaf' output.jpg
This transforms the pixels I want to red color.

Now I want those pixels to change its opacity, or to be lighten.

So, I tried:

Code: Select all

convert input.jpg -region 73x31+45+36 -fuzz 8% -fill red -colorize 10% -opaque '#a9afaf' output.jpg
But it lights ALL the region, not just the pixels I chose by using opaque and fuzz.

What can I do to change the brightness of the selected pixels? (The ones colored in red in the first example).

Thank you very much!!!
Last edited by agoyen on 2016-02-13T18:09:39-07:00, edited 2 times in total.
agoyen
Posts: 4
Joined: 2016-02-13T14:39:43-07:00
Authentication code: 1151

Re: Light a region

Post by agoyen »

In order words... I need to change the opacity, brightness, luminosity or similar of a particular color. Is it possible?

Like 'opaque' but instead of replacing a color to another color, change its opacity, brightness, luminosity (which should replace the color as well, but automatically getting the darker o brighter one).

Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Light a region

Post by fmw42 »

try

to change brightness and/or contrast

Code: Select all

convert input.jpg -region 73x31+45+36 -brightness-contrast 20,10 +region output.jpg
to change opacity (make it 75% opaque)

Code: Select all

convert input.jpg -region 73x31+45+36 -alpha set -channel a -evaluate set 75% +channel +region output.jpg
agoyen
Posts: 4
Joined: 2016-02-13T14:39:43-07:00
Authentication code: 1151

Re: Light a region

Post by agoyen »

Hello fmw24 and thanks for your answer!!

I think I could not explain myself properly.
I need the opacity/brightness of the color '#a9afaf' in the region to be altered, not the entire region.

Do you know how can I do it?

Thanks again!
agoyen
Posts: 4
Joined: 2016-02-13T14:39:43-07:00
Authentication code: 1151

Re: Light a region

Post by agoyen »

I mean... (color '#a9afaf' with -fuzz 8%) represents the pixels I want to change :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Light a region matching colors

Post by fmw42 »

Can you provide your input image? You can post to some free service such as dropbox.com and put the URL here. Otherwise, try the following to change the a9afaf (which is the same as a9afafff but has specified fully opaque alpha) to about half transparent as a9afaf88.

Note you cannot save to jpg, since jpg does not support transparency. So I have saved to png.

Code: Select all

convert input.jpg -region 73x31+45+36 -channel rgba -fuzz 8% -fill '#a9afaf88' -opaque '#a9afafff' +region output.png

Please, always provide your IM version and platform when asking questions, since syntax may differ.

See viewtopic.php?f=1&t=9620
Post Reply