Alter brightness and contrast of parts of an image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
spirofantasio1
Posts: 3
Joined: 2013-04-14T07:08:34-07:00
Authentication code: 6789

Alter brightness and contrast of parts of an image

Post by spirofantasio1 »

I'm not very advanced and when it comes to Imagemagick I would rather stick to command-prompt rather than Perl or other advanced programming.

Bascially, what I want to do is vary the brightness and contrast of parts of an image rather than the whole thing. Something like this:

Image

Can it be done? Thank you.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Alter brightness and contrast of parts of an image

Post by snibgo »

Your image didn't come through. But yes, that's easy. For example:

Code: Select all

convert img.png -mask mask.png -level 30%%,60%% +mask imgOut.png
This takes img.png, changes the brightness and contrast but only where the mask is black, with the effect fading to nothing where the mask is white.

See http://www.imagemagick.org/script/comma ... s.php#mask
snibgo's IM pages: im.snibgo.com
spirofantasio1
Posts: 3
Joined: 2013-04-14T07:08:34-07:00
Authentication code: 6789

Re: Alter brightness and contrast of parts of an image

Post by spirofantasio1 »

Sorry, I was not very clear. What I want to do is vary the brightness and contrast of parts of the image in order to make little squares appear but keeping the background essentially intact.

Here's a link to the kind of image I want to end up with:
http://img295.imagevenue.com/img.php?im ... _496lo.jpg
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Alter brightness and contrast of parts of an image

Post by Bonzo »

I had two other windows open as well as the image when I followed that link and one was a porn link :(

As snibgo said create a mask with square black boxes where you want the light areas.
spirofantasio1
Posts: 3
Joined: 2013-04-14T07:08:34-07:00
Authentication code: 6789

Re: Alter brightness and contrast of parts of an image

Post by spirofantasio1 »

Sorry about the links to the porn sites. When I uploaded the image I did specify that this was a family-friendly image and my Firefox is designed to block pop-up boxes so I was unaware of this.

Anyway, I researched the "mask" option and this led to the "region" option which provided me with what I required:

convert flowers.jpg -region 115x140+45+10 -brightness-contrast -70x-20 -region 115x140+45+170 -brightness-contrast -70x-20 flowers2.jpg

Thank you for the pointers.
Post Reply