Board index » delphi » store black pixels

store black pixels

Hi People:

I have a binary image, pf1bit (bmp).
I want to store only the black pixels with the Scanline property.
How do I make it, please?

Something like this

for i := 0 to Bitmap.Height
  Row := Bitmap.ScanLine[i]
  for j := 0 to Bitmap.Width
    if Row[j] = BLACK PIXEL then
    ....

Thank you very much.

 

Re:store black pixels


Eduardo Akira Yonekura <akir...@matrix.com.br> wrote in message
news:7o82bj$n5013@forums.borland.com...

Quote
> Hi People:

> I have a binary image, pf1bit (bmp).
> I want to store only the black pixels with the Scanline property.
> How do I make it, please?

> Something like this

> for i := 0 to Bitmap.Height
>   Row := Bitmap.ScanLine[i]
>   for j := 0 to Bitmap.Width
>     if Row[j] = BLACK PIXEL then

With pf1bit bitmaps there are 8 bits packed into a byte.
For additional info about pf1bit using Scanline, take a look at
http://www.efg2.com/Lab/ImageProcessing/Scanline.htm
and
http://www.efg2.com/Lab/ImageProcessing/pf1bit.htm

___
efg

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Re:store black pixels


On Tue, 3 Aug 1999 21:47:19 -0300, "Eduardo Akira Yonekura"

Quote
<akir...@matrix.com.br> wrote:
>I have a binary image, pf1bit (bmp).
>I want to store only the black pixels with the Scanline property.
>How do I make it, please?

>Something like this

>for i := 0 to Bitmap.Height
>  Row := Bitmap.ScanLine[i]
>  for j := 0 to Bitmap.Width
>    if Row[j] = BLACK PIXEL then

I think you mean you want to detect whether a given pixel is black,
right? Do something like this:

 const
   Mask: array[0..7] of Byte = 128, 64, 32, 16, 8, 4, 2, 1;
 var
   Row: PByteArray;
   I, J: Integer;
 begin
 for I := 0 to Bitmap.Height - 1 do begin
   Row := Bitmap.ScanLine[I];
   for J := 0 to Bitmap.Width - 1 do
     if (Row[J div 8] and Mask[J mod 8]) <> 0 then
       // pixel is black
     else
       // pixel is white
   end end;

Note that "black" and "white" are relative terms; it's possible for a
monochrome bitmap to have a palette that assigns other colors.

-Steve

Other Threads