Board index » delphi » LOOKING FOR: algorithm or method for processing pixels in an image

LOOKING FOR: algorithm or method for processing pixels in an image

Quote
Mark Vogt wrote:

> Hi all,

> I want to process on the individual pixels in an image, but don't know
> how to access the individual pixels.

> Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
> is a common (public domain) method for accessing the color of each pixel
> individually?

> For example, given a (say) GIF image, I want to be able to store the
> image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
> pixel as IMAGE[i,j].

> I'm guessing this is all very academic, but I'm stumped as to how to
> begin.

Every Canvas is Delphi has a "Pixels" property that is
a 2-dimensional array of TColor.

So you can look at, or define, any pixel in a Canvas,
e.g.,

    Canvas.Pixels[i,j := clRed

or  

    Color := Canvas.Pixels[i,j]

Any program that accesses individual pixels this way
will be slow, but will be more readable than various
assembler tricks.

--
Earl F. Glynn          EarlGl...@WorldNet.att.net
EFG Software              913/859-9557  Voice/Fax
   Scientific/Engineering/Medical Applications
             Overland Park, KS  USA

 

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Hi all,

I want to process on the individual pixels in an image, but don't know
how to access the individual pixels.

Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
is a common (public domain) method for accessing the color of each pixel
individually?

For example, given a (say) GIF image, I want to be able to store the
image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
pixel as IMAGE[i,j].

I'm guessing this is all very academic, but I'm stumped as to how to
begin.

Help Help Help...

Mark

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Quote
Mark Vogt <m...@pondscum.com> wrote:
>Hi all,
>I want to process on the individual pixels in an image, but don't know
>how to access the individual pixels.
>Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
>is a common (public domain) method for accessing the color of each pixel
>individually?
>For example, given a (say) GIF image, I want to be able to store the
>image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
>pixel as IMAGE[i,j].

I have no Idea, how the canvas.pixel property works, its maybe the
same as my idea, but.... but, another way to access to an array of
pixels is given with the win32-api-function 'CreateDIBSection'. Take a
look in win32.hlp, you have direct access to the DIB-Bitmap
memory-block, but you have to call BitBlt to make changes visible.

Markus
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(Remove $$ to mail me)
Markus Pfau
Aachen-Germany

Markus.P...@post.rwth-aachen.de

Re:LOOKING FOR: algorithm or method for processing pixels in an image


[This followup was posted to comp.lang.pascal.delphi.components.misc and
a copy was sent to the cited author.]

In article <32E817A7.6...@pondscum.com>, m...@pondscum.com says...

Quote
> Hi all,

> I want to process on the individual pixels in an image, but don't know
> how to access the individual pixels.

> Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
> is a common (public domain) method for accessing the color of each pixel
> individually?

> For example, given a (say) GIF image, I want to be able to store the
> image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
> pixel as IMAGE[i,j].

> I'm guessing this is all very academic, but I'm stumped as to how to
> begin.

> Help Help Help...

> Mark

Hey Mark. If you use bitmap as your format, then all you need to do is
create a bitmap in memory and do a LoadFromFile to fill it with the
correct image. Then, you can look at the Pixels array property of the
bitmap's canvas. By accessing Pixels[X,Y: LongInt], you'll get a TColor
for the pixel at that location.

Richard Porter

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Mark,
  Try looking in the online help under Pixels Property.  I think this gives
you what you want.

Hope this helps!
--
Rod Geraghty (:>)
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Mark Vogt <m...@pondscum.com> wrote in article
<32E817A7.6...@pondscum.com>...

Quote
> Hi all,

> I want to process on the individual pixels in an image, but don't know
> how to access the individual pixels.

> (Snip)

> Mark

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Quote
> Every Canvas is Delphi has a "Pixels" property that is
> a 2-dimensional array of TColor.

> So you can look at, or define, any pixel in a Canvas,
> e.g.,

>     Canvas.Pixels[i,j := clRed

> or  

>     Color := Canvas.Pixels[i,j]

> Any program that accesses individual pixels this way
> will be slow, but will be more readable than various
> assembler tricks.

> --
> Earl F. Glynn          EarlGl...@WorldNet.att.net
> EFG Software              913/859-9557  Voice/Fax
>    Scientific/Engineering/Medical Applications
>              Overland Park, KS  USA

There is a way to access pixelinformation faster without using assembler.
You can use the GetDIB function. The function is not easy to use, but is
explained in the Components Writers Help.

Bengt Karlstr?m,
ProComp Software

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Mark:

If you want lots of information about graphics file formats then pick up
the following book:

Graphics File Formats
2nd Edition,
Ja,es D. Murray & William van Ryper
O'Reilly & Assoc.
ISBN 1-56592-161-5

It has a CD with lots of code & samples and the usual giveaways of
shareware.

Windows NT4.0 seems to have a lot more functions available in the full
Win32 library - like world transforms. Somebody said they were slow, but
you didn't ask for fast now did you? :)

Quote
Mark Vogt wrote:

> Hi all,

> I want to process on the individual pixels in an image, but don't know
> how to access the individual pixels.

> Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
> is a common (public domain) method for accessing the color of each pixel
> individually?

> For example, given a (say) GIF image, I want to be able to store the
> image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
> pixel as IMAGE[i,j].

> I'm guessing this is all very academic, but I'm stumped as to how to
> begin.

> Help Help Help...

> Mark

--
___________________
Regards,
Dave Robinson, VP Development
Amber Computer Systems Inc.

WEB page: http://mindlink.net/amber_computer/
Components Page: http://mindlink.net/amber_computer/comp01.htm

ASAP-RTS Manufacturing Scheduling and shop floor data collection with
bar coding, and product tagging.  
Databases from directories - an OCR and Scanning system to create
marketing databases from directories.

Re:LOOKING FOR: algorithm or method for processing pixels in an image


Quote
Dave Robinson wrote:

> Mark:

> If you want lots of information about graphics file formats then pick up
> the following book:

> Graphics File Formats
> 2nd Edition,
> Ja,es D. Murray & William van Ryper
> O'Reilly & Assoc.
> ISBN 1-56592-161-5

> It has a CD with lots of code & samples and the usual giveaways of
> shareware.

> Windows NT4.0 seems to have a lot more functions available in the full
> Win32 library - like world transforms. Somebody said they were slow, but
> you didn't ask for fast now did you? :)

> Mark Vogt wrote:

> > Hi all,

> > I want to process on the individual pixels in an image, but don't know
> > how to access the individual pixels.

> > Can anyone suggest an image format (bmp, gif, jpg, tiff) for which there
> > is a common (public domain) method for accessing the color of each pixel
> > individually?

> > For example, given a (say) GIF image, I want to be able to store the
> > image in an array IMAGE[HEIGHT, WIDTH]that I can access an individual
> > pixel as IMAGE[i,j].

> > I'm guessing this is all very academic, but I'm stumped as to how to
> > begin.

> > Help Help Help...

> > Mark

> --
> ___________________
> Regards,
> Dave Robinson, VP Development
> Amber Computer Systems Inc.

> WEB page: http://mindlink.net/amber_computer/
> Components Page: http://mindlink.net/amber_computer/comp01.htm

> ASAP-RTS Manufacturing Scheduling and shop floor data collection with
> bar coding, and product tagging.
> Databases from directories - an OCR and Scanning system to create
> marketing databases from directories.

Or you could check out this place:
http://www.dcs.ed.ac.uk/%7Emxr/gfx/
Perhaps this guy can help.
--
TheHunter/-97

Re:LOOKING FOR: algorithm or method for processing pixels in an image


A TImage already has a Pixels property which act as an array
for the Pixels.

Image1.Canvas.Pixels[x,y]:= {a TColor value };

Other Threads