?
Solved

TColor and how to get Colour Range

Posted on 1998-07-14
4
Medium Priority
?
813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

719 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