Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:17:20+00:00 2026-05-25T11:17:20+00:00

I have an image whose pixel colors I want to change to match a

  • 0

I have an image whose pixel colors I want to change to match a particular color (though not completely).

As an example, I want to tint the image of a red car so that it appears blue. I can do this with the GIMP and with ImageMagick, but I would like to know which algorithm they are using to do this so I can implement it in my own program.

I have tried to do this with simple addition of the difference between the colors but it doesn’t work very well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:17:21+00:00Added an answer on May 25, 2026 at 11:17 am

    As just a shot in the dark, untested suggestion from someone who’s getting into image processing fairly recently… maybe you could just scale the channels?

    For example:

    RGB_Pixel.r = RGB_Pixel.r * 0.75;
    RGB_Pixel.g = RGB_Pixel.g * 0.75;
    RGB_Pixel.b = RGB_Pixel.b * 1.25;
    

    If you loop through your image pixel-by-pixel with those three changes, I’d expect you to see the image shift towards blue, and the numbers of course can be trial-and-error’d.

    EDIT:
    Now if you want to ONLY change the color of pixels that are a certain color to begin with, say, you want to turn a blue car red without doing anything to the rest of the picture, you’ll need to run a check on each pixel to see what color it looks like. One way to do this is to use a Euclidean distance:

    int* R = RGB_Pixel.r;
    int* G = RGB_Pixel.g;
    int* B = RGB_Pixel.b;
    
    // You are looking for Blue, which is [0 0 255];
    // this variable D is the distance of your current pixel from the desired color.
    float D = sqrt( (R-0)*(R-0) + (G-0)*(G-0) + (B-255)*(B-255) );
    
    if(D < threshold)
    {
        R = R * 0.75;
        G = G * 0.75;
        B = B * 1.25;
    }
    

    The threshold variable is a number between 1 and 255 that represents the maximum distance a color can be from the color you’re looking for and still be considered “close enough”. This is because you don’t want to only look for [0 0 255], very rarely will you find perfect blue (or perfect anything) in an image.

    You want to use the lowest threshold you can get away with so that you don’t end up coloring other things that aren’t part of the object you’re looking for, but you want to make sure your threshold is high enough that it covers your entire image. One way to do this is to set up multiple D variables, each with a different target color, so you can capture a few separate types of “blue” without using a really high threshold. For instance, to the human eye, [102 102 200] looks like blue, but might require a pretty high threshold to catch if [0 0 255] is your target color.

    I suggest playing with this calculator to get a feel for which colors you want to search for specifically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i have an image matrix and i am at a particular pixel [say
I have an image in a C# WPF app whose build action is set
I have an app whose navigation tree is described on the attached image. Basically,
i have a problem with cutting an image. What i want to do is,
I have to render a very big image (>50.000² pixel) with cairo. To do
I want to change the color of human skin to blue, like in the
I have a script that creates an image whose height depends on the depth
I have a UIImage containing an image with a whole bunch of smaller pictures
I have a UITableView whose cells contain custom ImageViews that asynchronously load the images
I have image Array with two images out of that first image its showing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.