gray code bit plane matching stabilizeing method fully implemented