[Solved] Moving a sun on a black background to a blue back?

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
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

[Solved] Moving a sun on a black background to a blue back?

Post by owntheweb »

Howdy,

Image

I have a live image of the sun from SDO (original on left) that I want to incorporate into a design dynamically. In order to do this I need to replace the black background with a blue one (see right image for general idea, created with Photoshop for demo purposes).

If I do a simple color replace of black to blue, I get the middle image as a result naturally. This is rather rigid and ugly though, so I need something that will deal with multiple shades and keep as much of the orange/blue combo looking nice as possible.

I was going to write something for use in GD, but ImageMagick has a lot of functions that may handle this more elegantly? What are your thoughts on getting started?

Thanks for the feedback in advance. :D

Best regards,

Chris
Last edited by owntheweb on 2012-05-19T07:55:21-07:00, edited 1 time in total.
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Moving a sun on a black background to a blue background?

Post by fmw42 »

see right image for general idea, created with Photoshop for demo purposes
I don't see any right image with any blue background!

Have you tried using a -fuzz XX% with your color replacement?

convert image -fuzz XX% -fill blue -opaque black result
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: Moving a sun on a black background to a blue background?

Post by owntheweb »

I got it figured out:

Image
SDO Sun Image Moved From Black to Blue Background by ultrus, on Flickr

Using clutImage() with PHP's Imagick class did wonders. I used a 2D Clut image to change black to dark blue and gradient after that. See this page for more info on how it all works:
http://www.imagemagick.org/Usage/color_mods

It looks better than what I could do in Photoshop! :D

Best regards,
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Moving a sun on a black background to a blue background?

Post by fmw42 »

glad you solved it. but both images look like they have a black background (visually), so your dark blue must be very close to black. that was what was confusing to me.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Moving a sun on a black background to a blue background?

Post by Bonzo »

but both images look like they have a black background
Probaly time to calibrate your monitor :?
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

Re: Moving a sun on a black background to a blue background?

Post by owntheweb »

Yeah it's a pretty dark blue (#001427), but do calibrate your monitor. The world of color awaits! :D
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Moving a sun on a black background to a blue background?

Post by fmw42 »

owntheweb wrote:Yeah it's a pretty dark blue (#001427), but do calibrate your monitor. The world of color awaits! :D
I recalibrated, but it still looks pretty much black to me (on Mac monitor)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Moving a sun on a black background to a blue background?

Post by anthony »

You may like to try the global color modification tha was developed for weather maps.
Mathematical Non-linear Histogram Adjustments
http://www.imagemagick.org/Usage/color_mods/#non-linear

This basically adjusts the blue channel to never approach zero, though was designed with gray-scale images in mind.

For your image blue adjustment could be adjusted to only adjust blue channel relative to the overall brightness of the image, so that red and yellow colors do not get a blue component.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
owntheweb
Posts: 20
Joined: 2011-05-24T06:30:15-07:00
Authentication code: 8675308
Location: Colorado

RESOLVED: Moving a sun on a black background to a blue back?

Post by owntheweb »

Sorry to bring this old post back to life. I forgot to share the success of this experiment. A live sun background is now being featured at:

http://www.spacefoundation.org

At the moment I don't recall all the specific details, but the secret sauce was using -clut, combined with some cropping and an alpha mask (better preserving the orange in the center of the sun):
http://www.imagemagick.org/Usage/color_mods/#clut_alpha
Twitter | Blog | Worlds to explore. Worlds to create.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: [Solved] Moving a sun on a black background to a blue ba

Post by anthony »

The clut approach applied globally may produce some changes elsewhere on the image.
More details of the CLUT technique would be nice :) , but if you don't remember :roll:

However by using some masking to restrict what areas the clut is applied you can prevent that.

Fred if you can not see the blue, then your monitor must have a a very high 'gamma' setting. I have heard that most Mac Monitors do have a non-standard gamma.

Actually my workstation monitor has a low gamma at the bottom and a higher gamma at the top of the screen! -- And it is a new monitor (I don't get much say about it as the university bought it for me :-( )
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply