Jump to content

Color replacement: Place sun from black background to blue background?


ultrus

Recommended Posts

Howdy,

 

6052379813_d4ca73afe1_z.jpg

 

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.

 

Do you know of a good way to do this using GD or ImageMagick (using Imagick)? So far ImageMagick seems more elegant.

 

Thanks for the feedback in advance.  :D

 

Best regards,

 

Chris

Link to comment
Share on other sites

with it being black hue and saturate wont work.

just use magic wand tool and set the tolerance higher so it grabs out most of the black... along with it will be some of the sun but i can see a way to avoid that.

Link to comment
Share on other sites

I'm not looking to use Photoshop's magic wand tool (I did that for the right image above for demo). I'm looking to use GD or ImageMagick to accomplish this using PHP. I'll be incorporating a live image of the sun into my design (doing this once per hour with Photoshop would kill me).  :P

Link to comment
Share on other sites

So far I'm finding this to be interesting:

 

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

$image = new Imagick('latest.jpg');
$clut = new Imagick('hald.png');
$image->clutImage($clut);
$image->writeImage('test_out.jpg');
?>

<img src="test_out.jpg" alt="sun" />

 

Looks TERRIBLE!... but it does use a color lookup table to replace colors. I'm learning more about "hald" and "clut" now...

http://www.imagemagick.org/Usage/color_mods/#hald_replacement

 

EDIT:

It looks like there's clutImage() and haldClutImage(). Sadly haldClutImage() is not supported on my server (docs say may be svn only). :(

 

Looking into alternatives...

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

I got it figured out:

 

6053663834_696f59a716_z.jpg

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

 

Using clutImage() did wonders. Instead of a 3D Hald Clut image, 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

 

Best regards,

Link to comment
Share on other sites

Increase contrast until you get a good black and white mask, if possible.

 

Use a feather solution like this

http://www.fmwconcepts.com/imagemagick/feather/index.php

 

You should then be able to apply the feathered mask to the image.

 

Not super familiar with imagemagick, so I can't help further at the moment. Keep us updated though, it'll be a very cool function.

 

edit - Wow, that looks great.

Link to comment
Share on other sites

With the link he posted, check out the 'Recoloring Images with Lookup Tables' area. It pretty much explains how to do it.

 

His method would run into more issues with a lighter background, in that case, you'd have to use a mask like I was suggesting, and apply the color table based on the mask.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.