Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Retrieving Image from memory

Status
Not open for further replies.

pravish

Newbie level 5
Newbie level 5
Joined
Feb 25, 2006
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,354
hi there,
i have a camera that, on interfacing, gives me the bitmap image into a memory alignment in the 'unsigned char'(BYTE) format...I m using VC++ 6.0 for some image processing stuff. I only require the rgb values of every pixel to process the image further. My question is that how do i retrieve the rgb values frm unsigned char format since they are 'int'(0-255)values.
KINDLY SUGGEST ME A SOLUTION
thanks
regards
 

**broken link removed**
 

Hi,

If the camera is 256 colours (one byte per pixel), then usually the RGB
values are encoded such that 3 bits correspont to red, 3 bits for green,
and 2 for blue (since blue is needed less for distinguishing faces I think).
So, perhaps bits 0-1 are blue, bits 2-4 are green and bits 5-7 are red.

If the camera is 65536 colours, then it is 2 bytes per pixel, so there are more bits
for red, green and blue. I cannot remember the exact amount, but if you need
more help let me know.

So, if it is a 256 colour camera, then you could get (say) the Red value as follows:
unsigned char red=(pixel & 0xe0)>>5;
(0xe0 is the mask for the 3 MSB, and then you right-shift by 5, to get it in a
range of 0 to 7, where 0 is no red, and 7 is brightest red. So you could then multiply by some factor, to get it into any range that you want, e.g. 0 to 100).

You do a similar thing for green and blue.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top