The software on the computer accomplishes three main goals: importing a picture, identifying contiguous groups and connecting them, and determining how to draw the picture. This is all done in Python.
Importing a Picture
Using the Python Imaging Library, we can import various types of images (including JPEG, BMP, and PNG) into Python. Once we have the original picture (as seen above), we apply a smoothing filter, and then a edge filter. This gives a picture with white lines signifying edges against a black background.
Next, keeping in mind the limited drawing accuracy and precision of the Etch-a-Sketch, we smooth the picture, blur it, and resize it, making it smaller.
From here, we first remove any edges that are too small to draw. These are mainly small lines that are isolated from the main part of the picture. After we have this final image, we iterate through the image and read the pixel value of each location. If it is brighter than a certain threshold value, we regard that pixel as drawn.
Contiguous Groups
Once we have the picture imported, we have a two dimensional grid of pixels, each either on (red) or off (gray). We can now identify groups of pixels that are to be drawn. Because an Etch-a-Sketch cannot move without drawing (as the stylus cannot be lifted off the screen), we must connect these groups of pixels. However, we want to do this in a way that minimally alters the picture. We accomplish this by only connected the two closest groups at any time and iterating until all pixels are connected.
You can see the pixels needed to connect the pixels in green. Now that we have one contiguous block of pixels, now we need to determine how to draw the picture. After inputting a starting location, we make the list of drawing commands (up, down, left, right) by always trying to go to the nearest pixel that has not yet been drawn. After we have the list of commands, each command is sent to the PIC one at a time.