# What is visual cryptography?

Question:
1. What is visual cryptography?
2. How does it work for secret image sharing?

Attempt: I have tried to understand the concept of secret image sharing for black and white pixel from here http://www.datagenetics.com/blog/november32013/. But I have doubt about pixel expansion in this case. Suppose I have a image $212\times 212$ pixels. How can I encode this image to use as cipher text using pixel.

• Basically, you make sure that the combined 4-pixel gives all black if the source pixel is black, and gives half black if the source pixel is white. – Kenny Lau Apr 24 '16 at 1:42
• @KL, thank you for your kind response. Due to my network problem I am late. I shall update my post with example. – Warrior Apr 24 '16 at 2:10

The rule is already given here:

Let $$\begin{matrix}\blacksquare\square\\\square\blacksquare\end{matrix}$$ be pattern 1 and $$\begin{matrix}\square\blacksquare\\\blacksquare\square\end{matrix}$$ be pattern 2.

Notice that they add up to a black square, and when added to themselves, they create a half-black square.

If the source pixel is black:

• For half of the time, give pattern 1 to the first encrypted image and pattern 2 to the second encrypted image.
• For the other half of the time, give pattern 2 to the first image and pattern 1 to the second.

If the source pixel is white:

• For half of the time, give pattern 1 to the first encrypted image and the second encrypted image.
• For the other half of the time, give pattern 2 instead.

### Variations

As stated in the website, they do not have to be a checkerboard pattern.

As long as pattern 1 is the complement of pattern 2, i.e. they share no common black pixel and they add up to a large black pixel, then you can use them. You are also encouraged to use different varieties.

### Program:

In Pyth:

J.z          "assign the inputs to J" \
=GmmO6lhJlJ  "assign G to an array filled with random" \
"numbers from 0 to 5, each corresponding" \
"to a pattern" \
=H.e.e?q@@JkY"■"-5ZZbG \
"assign H to G, then flip the number if" \
"the corresponding pixel is black"
jbmsMdG\
jbmsMdH     "print both arrays"


Try it online!

Correspondence:

• 0 corresponds to $$\begin{matrix}\blacksquare\blacksquare\\\square\square\end{matrix}$$.
• 1 corresponds to $$\begin{matrix}\blacksquare\square\\\blacksquare\square\end{matrix}$$.
• 2 corresponds to $$\begin{matrix}\blacksquare\square\\\square\blacksquare\end{matrix}$$.
• 3 corresponds to $$\begin{matrix}\square\blacksquare\\\blacksquare\square\end{matrix}$$.
• 4 corresponds to $$\begin{matrix}\blacksquare\square\\\blacksquare\square\end{matrix}$$.
• 5 corresponds to $$\begin{matrix}\square\square\\\blacksquare\blacksquare\end{matrix}$$.

They are deliberately assigned so that if their code add up to 5, then the pixels add up to a large black pixel.

• @ KL, it will better if you do this. +1 for you. – Warrior Apr 24 '16 at 2:12
• @Warrior Please tell me if you need another input format. I am aware that the current input format is not so useful. – Kenny Lau Apr 24 '16 at 2:19
• if every pixel is divided into say 2 subpixels horizontally, then this would increse the width of the superimposed image by a factor of 2?? – Upstart Oct 5 '17 at 9:24