Thread: Image Analyzing
View Single Post
  #4   Spotlight this post!  
Unread 05-02-2012, 01:17
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Image Analyzing

The exact method would depend on the language, but you generally want a few things: a pointer to the image data, a width and height, and color information, primarily format (RGB, RGBA, BGR, grayscale etc.) and channel depth (a 32-bit RGBA image has 4 color channels, and therefore has an 8-bit channel depth. A 24-bit RGB image has only 3 channels but the same channel depth). Once you have this, accessing the nth (where n=0 is the first) channel of a specific pixel would go something like this:
Code:
pixels[(y*width+x)*bytesPerPixel + n]
where bytesPerPixel would be 4 for a 32-bit image, 3 for a 24-bit image, etc., x and y are in pixel units, width is the number of pixels per scanline, and pixels is a byte*, byte[], uint8_t*, uint8_t[], or whatever byte array or byte pointer type is provided by your language of choice.