Solved

TColor and how to get Colour Range

Posted on 1998-07-14
4
804 Views
Last Modified: 2006-11-17
My question is as follows....

 I am writing a program for a sports medicine practice. It involoves importing an avi made using a video capture device. Now when I import the image into delphi I have options on a TImage to change the number of colours ie 32bit, 16bit  etc. My question involves the actual colours themselves and how they are listed in the 16million colour format. For example ... if the image has a person in it an on that person there are yellow markers as I perceive it.
Now to pick out all the colours on that yellow maker for instance may require me to check the range (converted from Hex) of 4,000,000 to 16,000,000 . Is there a definite scale of Yellow, Blue, Red etc that will not miss out any colours as in delphi3 help i can only see the absolute colours listed for example white is $00FFFFFF and black is
$00000000 . Now yellow will vary based on intensity and i guess that is my question how can you list/get the colurs
in a range based on their intensity ie from least intense to most intense but not moving out of the actual colours range. I use Canvas.Pixels[x,y] to get the pixel colour. Can anyone help me?

Thanks in advance
Westy
0
Comment
Question by:westy100697
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1357904
In 24 bit color mode, all colours are RGB triplets (this is also true for 32 bit, except there is also an alpha channel which you won't need to worry about).

Delphi defines Yellow as $00FFFF. Note that in this notation the order of colours is BGR, so this is no blue and full intensity green and red.

So, a range of yellow intensities can be given by the range of values $000000 to $00FFFF where the green and red value are the same (although often they will be similar so you could make sure they were within 5% of each other).

In your application the Blue channel is unlikely to be zero all the time so you might want to permit a low level of blueness (perhaps up to 5%).

That should allow you to match a wide range of 'yellow' colours.

0
 

Author Comment

by:westy100697
ID: 1357905
So using the pixels property of the canvas you are given a longint value so how can you tell exactly what colour has been chosen if as you say it is in BGR format instead of RGB format if you see what i mean because when you convert back to hex you won't know what order it is in or will you. Is there some way of telling this?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1357906
Sure is.

The Pixels property returns a TColor which is a longint with the low order 3 bytes containing BGR channels, 8 bits per channel. So to get each channel do this:

Blue = (Pixels[x, y] AND $FF0000) SHR 16
Green = (Pixels[x, y] AND $00FF00) SHR 8
Red =  Pixels[x, y] AND $0000FF

The pixels property is not very fast so if performance becomes an issue you may want to access the memory directly.

0
 

Author Comment

by:westy100697
ID: 1357907
Thanks very muchly appreciate the input and here are the points .

Westy 8-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now