Deal with the binary issue

I need to come up with a new way to make a matrix with the binary value for the hidden image as individual bits.  Use a while loop while appending new values to (i)