Hi,
For 8 bit codes, 36 is just what comes out from the rotation invariant
condition.
The rule is that the binary codes are invariant to rotation. One way of
implementing this is to normalize all the codes to the minimal value of
all rotations (this value is called the pivot and aggregates all values
it represents). That is, you take each value, you try all possible
binary rolls and you take the minimal value. So, code 1 will actually
represent 1, 2, 4, 8, 16...; code 3 (0000 0011) will also represent 6
(0000 0110), 12 (0000 1100)...; code 5(000 0101) will also represent 10
(0000 1010)...
Now, we can just count how many of these pivots there are.
For 8 bit codes, a 1 bit roll can be implemented like this:
def roll1(i):
return ((i << 1) & 0xff) + bool(i & 128)
Now, we can check whether a binary value is a pivot using this basic
loop:
def is_min(v):
i = v
for _ in range(8):
i = roll1(i)
if i > v:
return False
return True
Ok, so how many pivots are there?
n_pivots = sum([is_min(i) for i in range(256)])
It's 36.
HTH
--
Luis Pedro Coelho | EMBL |
http://luispedro.org
My blog:
http://metarabbit.wordpress.com
> --
> You received this message because you are subscribed to the Google Groups
> "pythonvision" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
pythonvision...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.