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 6944959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:22:28+00:00 2026-05-27T13:22:28+00:00

Is it possible to classify html hex colours into simple string values?? For example,

  • 0

Is it possible to classify html hex colours into simple string values??

For example, the colour #CC3333, it’s not completely red, but as a human we can assume that it’s red. The colour #CCCCCC can be classified as white, because I don’t want black or grey involved.

Possible simple values at least consist of:

  • red
  • white
  • green

More classification is better, but I want at least these colours.

Can it be done?

Optional info:

I’m creating a web apps that capture the pictures through webcam. The user can hold a white or red paper to the webcam and the apps detect the image’s major colour. Then the user will be redirected to a different options depending on their colour. I’ve done the colour detection, but I just want classify it into several colour only, red,white,and green.

  • 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-27T13:22:28+00:00Added an answer on May 27, 2026 at 1:22 pm

    This is a somewhat subjective question, because yes it can be done, but exactly how you would do it would depend on your specific application – colour itself is very subjective in the way that it is observed by the individual.

    You would need to start by splitting the string into it’s red, green and blue components:

    $colourId = 'CC3333';
    list($red, $green, $blue) = str_split($colourId, 2);
    

    Then, it would probably be an idea to convert them to integers:

    $red = hexdec($red);
    $green = hexdec($green);
    $blue = hexdec($blue);
    

    Then you need to apply some sort of logic to it to determine which one of your classes it falls into. How you do this is really up to you, but maybe you could do something like this:

    if (max($red, $green, $blue) - min($red, $green, $blue) < 10) {
      // If the values are all within a range of 10, we'll call it white
      $class = 'white'; 
    } else if (max($red, $green, $blue) == $red) {
      // If red is the strongest, call it red
      $class = 'red'; 
    } else if (max($red, $green, $blue) == $green) {
      // If green is the strongest, call it green
      $class = 'green'; 
    } else if (max($red, $green, $blue) == $blue) {
      // If blue is the strongest, call it blue
      $class = 'blue'; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: Parse string into argv/argc I'm trying to write a fake shell using
Possible Duplicates: Is “for(;;)” faster than “while (TRUE)”? If not, why do people use
Possible Duplicate: Split A4 PDF page into two A5 and back again I have
Possible Duplicate: Truncate a multibyte String to n chars Hello, I'm developing a site
Possible Duplicate: why do we need to pass in window and undefined into this
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: What Ruby IDE do you prefer? I've generally been doing stuff on

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.