Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TColor and how to get Colour Range

Posted on 1998-07-14
4
Medium Priority
?
814 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

886 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