 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Paul Nicholls Guest
|
Posted: Tue Aug 23, 2005 5:59 am Post subject: Re: detecting pixels of certain color |
|
|
"SupportX" <SupportX (AT) SupportX (DOT) com> wrote
| Quote: | Subject: detecting pixels of certain color
Hi,
I have a small bitmap. I wish to scan one horizontal line in it (the
middle one) from left to right, and determine which points on this line
are black.
How to?
TIA,
SupportX
|
you have two options:
1) use TBitmap.Canvas.Pixels[x,y] - easiest by far, but slow!
2) use TBitmap.Scanline[] - more difficult to code, but much faster!
cheers,
Paul
|
|
| Back to top |
|
 |
Charles Hacker Guest
|
Posted: Tue Aug 23, 2005 6:06 am Post subject: Re: detecting pixels of certain color |
|
|
SupportX wrote:
| Quote: |
I have a small bitmap. I wish to scan one horizontal line in it (the middle one) from left to right, and determine which points on this line are black.
|
How close to black?
Lets assume black is colour (0-255) less than '4' intensity!
var Line: PByteArray;
X,Y,col: Integer;
Bitmap.Pixelformat:= pf24bit;
{note this code only works with 24 bit RGB color images}
col:= 0;
Y:= Bitmap.Height DIV 2;
Line:= Bitmap.Scanline[Y];
for X := 0 to Bitmap.Width-1 do
begin
// Red is Line[X*3 ]
// Green Line[X*3+1]
// Blue Line[X*3+2]
if (Line[X*3]<4 and Line[X*3+1]<4 and Line[X*3+2]<4) then
begin
// Color is black
INC(col);
end;
end;
ShowMessage(IntToStr(col)+' Pixels were black');
--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia
|
|
| Back to top |
|
 |
SupportX Guest
|
Posted: Tue Aug 23, 2005 6:49 am Post subject: detecting pixels of certain color |
|
|
Subject: detecting pixels of certain color
Hi,
I have a small bitmap. I wish to scan one horizontal line in it (the middle one) from left to right, and determine which points on this line are black.
How to?
TIA,
SupportX
|
|
| Back to top |
|
 |
SupportX Guest
|
Posted: Tue Aug 23, 2005 7:34 pm Post subject: Re: detecting pixels of certain color |
|
|
Subject: Re: detecting pixels of certain color
Thanks, worked like a charm!
|
|
| Back to top |
|
 |
Francesco Savastano Guest
|
Posted: Wed Aug 31, 2005 2:36 pm Post subject: Re: detecting pixels of certain color |
|
|
| Quote: | // Red is Line[X*3 ]
// Green Line[X*3+1]
// Blue Line[X*3+2]
|
Actually Red is Line[X*3+2] and Blue is Line[X*3 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|