putting bit-planes to good use
A standard PNG file format image is stored as a 3-dimensional array containing three slices of shape, $\text{height} \times \text{width}$. Each of these slices represent the three colour channels, $\text{Red, Green and Blue}$ which combine to form a familiar images that we see all around us. Now, each of these $\text{height} \times \text{width}$ slices usually contain an $8-bit$ number representing the intensity of the respective colour channel at that pixel’s location.
The property that we intend to exploit here:
The above property is better explained with the following example:
\[\text{Original 8-bit representation of the image} = B_{7}B_{6}B_{5}B_{4}B_{3}B_{2}B_{1}B_{0}\] \[\text{Image with only} \, n \, \text{of most significant bits} = B_7 B_6 \cdots B_{8 - n} \, \underbrace{0 0 \cdots 0}_{8 - n \text{ bits}}\]It is evident that the image retains most of its quality even when just first $4$ of its MSBs are used to represent it.
Now, we will exploit the above property for our simple encryption.
\[\text{Bit representation in the original visible image} = B_{7}B_{6}B_{5}B_{4}B_{3}B_{2}B_{1}B_{0}\] \[\text{Bit representation in the original image to be encrypted} = b_{7}b_{6}b_{5}b_{4}b_{3}b_{2}b_{1}b_{0}\] \[\text{Bit representation for our encrypted image} = B_{7}B_{6}B_{5}B_{4}b_{7}b_{6}b_{5}b_{4}\]Enough of ideas, let’s see it in action!
For decryption, we can simply separate the $4$ most significant and least significant bits from the encrypted image to get a the close approximations of the two original images.
Now if we look closely, some parts of the Edison’s image are still visible in the encrypted version. Hence, this method is definitely not full-proof. I suppose we will on the hunt for a good enough encryption technique in the coming few days, together.