grayscale to binary algorithm

On 25 Sep 2006 08:14:30 -0700, djin_n_tonic@yahoo.com wrote:

can you helpme turn an 8b grayscale byte into a binary byte?
google will tell you, if you ask nice.

Try "gray code"

John
 
djin_n_tonic@yahoo.com wrote:

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

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
 
In response to what <djin_n_tonic@yahoo.com> posted in
news:1159197269.932609.293650@e3g2000cwe.googlegroups.com:

can you helpme turn an 8b grayscale byte into a binary byte?
The easiest and fastest way is a lookup table.

--
Joe Soap.
JUNK is stuff that you keep for 20 years,
then throw away a week before you need it.
 
<djin_n_tonic@yahoo.com> schreef in bericht
news:1159197269.932609.293650@e3g2000cwe.googlegroups.com...
can you helpme turn an 8b grayscale byte into a binary byte?
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
 
<djin_n_tonic@yahoo.com> wrote in message
news:1159197269.932609.293650@e3g2000cwe.googlegroups.com...
can you helpme turn an 8b grayscale byte into a binary byte?
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
 

Welcome to EDABoard.com

Sponsor

Back
Top