grayscale to binary algorithm

can you helpme turn an 8b grayscale byte into a binary byte?

Reply to
djin_n_tonic
Loading thread data ...

google will tell you, if you ask nice.

Try "gray code"

John

Reply to
John Larkin

In response to what posted in news: snipped-for-privacy@e3g2000cwe.googlegroups.com:

The easiest and fastest way is a lookup table.

--
Joe Soap.
JUNK is stuff that you keep for 20 years,
 Click to see the full signature
Reply to
Joe Soap

if you were in a programming room, i would say you have a problem how ever, sense your here, i think you are referring to the Gray Code ? if so, i can give you the simply view of it, you will have to find the rest on the net. basically the idea is to not allow 2 or more bits to change state at the same time. it almost looks like binary but not in the same order. reason for this is to remove the chance of false indication while changing state. one bit could switch just before the other in the case where 2 or more bits change in the binary system! this could cause drastic problems in positioning detectors. off the top of my head just for an example here

0 = 0000 1 = 0001 2 = 0011 3 = 0010 4 = 0110 5 = 0111 6 = 1111 7 = 1110 8 = 1100 9 = 1101

the above is most likely not the standard use but it shows that only 1 bit at a time is changed between states. google for the standard in sequence.

--
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Reply to
Jamie

schreef in bericht news: snipped-for-privacy@e3g2000cwe.googlegroups.com...

In normal binary code, the value of a bit depends on the serial number:

a*2^(n-1)

in which a is the value of the bit (1 or 0) and n the serial number. A binary value of 8 bits becomes:

2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0

off course, each term multiplied with its own bit "a".

The numerical value of a Gray code can be denoted as:

(2^8-1) +/- (2^7-1) +/- (2^6-1) +/- (2^5-1)

+/- (2^4-1) +/- (2^3-1) +/- (2^2-1) +/- (2^1-1)

In which +/- means plus or minus and the bits "a" are not noted. The formula reads as follows: Neglecting the zero bits read from left to right plus term, minus term, plus term and so on.

To perform the translation, a lookup table is faster but requires more code space then calculation.

petrus bitbyter

Reply to
petrus bitbyter

If the bits are numbered left to right 1, 2, 3, 4 ...... Bit 1 is always the same in both codes. Compare natural binary bit 1 with the Gray bit 2 If they are the same the natural binary bit 2 is zero, 1 if different And so on

JD

Reply to
John Duffus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.