Week 2: Computer-Aided Design — Converting Raster to Vector Graphics
Project Overview
For my final project—the Magic Zoetrope—I want to use Zhang Daqian's copy of the Dunhuang mural "Late Tang Musical Instrument Two-Body Buddha" as source material for the rotating section. The mural depicts two flying deity figures, which I plan to print on semi-translucent paper in a cylindrical format. As the cylinder rotates, viewers will see the dancing musical instrument deities in motion.
Zhang Daqian's copy of the Dunhuang mural "Late Tang Musical Instrument Two-Body Buddha"
The two flying deity figures are perfect for the rotating pattern of the Magic Zoetrope
For this exercise, I aim to accomplish the following goals:
- Image Background Removal: I want to isolate the bodhisattva figures with a transparent background, allowing me to print them on any semi-transparent paper or transparent film used for the rotating cylinder.
- Convert to Black and White Line Art: Extract black and white line art from the color image.
- Vectorize the Line Art: Convert the black and white line art to vector format, preparing materials for the upcoming laser cutting course to experiment with laser engraving effects.
This process will help us understand the characteristics of different image formats while laying the foundation for subsequent digital manufacturing techniques.
Basic Concepts
Graphics and images are fundamental to computer-aided design, as we need them to express both our design intentions and processes. Before beginning the actual image conversion work, we need to understand two basic types of digital image representation: raster images (pixel-based) and vector graphics. Each format has its characteristics and plays different roles in digital design.
Raster Images
Raster images, also known as bitmap images, are composed of a grid of pixels. Each pixel contains specific color information, collectively forming the complete image.
Characteristics of raster images:
- Resolution dependent: Loses quality when enlarged
- Larger file sizes: Must store information for each pixel
- Suitable for: Photos and continuous-tone images
- Common formats: JPG, PNG, BMP, etc.
When raster images are enlarged sufficiently, you can see individual colored squares that make up the pixels, and the image becomes blurry
Vector Graphics
Vector graphics are based on mathematical equations, composed of geometric elements such as points, lines, curves, and shapes.
Characteristics of vector graphics:
- Resolution independent: Can be scaled without loss of quality
- Smaller file sizes: Only stores mathematical descriptions of graphic elements
- Suitable for: Logos, icons, technical drawings, etc.
- Common formats: SVG, AI, EPS, etc.
After vectorization, SVG images can theoretically be enlarged "infinitely"
:::tips In digital manufacturing, correctly choosing and converting image formats directly affects the final production quality. For example, laser cutting typically requires clear vector paths, while 3D printing texture maps are better suited for raster images. Understanding these basic concepts helps us make the right technical choices in subsequent digital manufacturing processes. :::
1. Background Removal
First, I obtained a high-resolution screenshot of the mural from Google Arts & Culture platform (https://g.co/arts/vR6XPac9VrxZzyzX8) and saved it as a PNG format, with dimensions of 2770x1372 pixels and approximately 4.5MB in size.
For image processing, I used Photoshop (PS), which I'm familiar with. After opening the mural image in PS, it provides a background removal function in a floating window.
Opening the mural image in PS
After clicking the "Remove Background" button, most of the background was removed, but there were some errors—some areas that should have been removed were kept, and some that should have been kept were removed.
The effect after using the background removal function, showing some errors
Note that a mask was added to the layer on the right, as shown below. A mask can be understood as a black and white image, where black represents hidden areas and white represents preserved areas.
PS adds a mask after removing the background. This mask can be understood as a grayscale image, where black indicates areas to remove, white indicates areas to show, and middle grays represent transparency
We can edit this black and white mask using the tools below, along with the Quick Selection tool, Brush tool, etc., to correct areas that need to be hidden or shown. Additionally, you can use the "x" key to quickly switch between "Remove from Mask" and "Add to Mask" functions; and use the "[" and "]" keys to control brush size for precise detail work.
After refining the mask, we now have the desired background removal effect, and I saved the PS file.
Then using PS's export function, we can see in the preview that saving as PNG results in 2.5MB. Since this image has relatively few colors, if we want to further reduce the file size, we can check "Smaller File (8-bit)", which will limit the image to 256 colors, reducing the file size to 598KB.
Now, we've successfully obtained a PNG image with a transparent background.
2. Converting to Black and White Line Art
- Copy and Desaturate: Continuing in PS, duplicate the original color layer in the layers panel (shortcut Ctrl+J, or Command+J on Mac), then desaturate the copied layer using Image>Adjustments>Desaturate (shortcut Ctrl+Shift+U, or Command+Shift+U on Mac), with the effect shown below:
The image effect after adding a grayscale adjustment layer.
- Copy and Invert: Continue in PS by copying the desaturated layer, then invert it using Image>Adjustments>Invert (shortcut Ctrl+I, or Command+I on Mac), with the effect shown below:
The effect after color inversion
- Color Dodge: In PS, change the blending mode of the inverted layer to Color Dodge, at which point the image will turn white, as shown below.
Set the inverted image's blending mode to "Color Dodge"
- Use the "Minimum" Filter: Use Filter>Other>Minimum from the menu bar, typically a radius value of 1 is sufficient. The effect is shown below.
The effect after using the Minimum filter
- Stamp Visible Layers: Select the 2 copied layers and use the shortcut Ctrl+Alt+E (Command+Alt+E on Mac) to stamp visible layers, then group the original layers and hide their visibility. The layers panel state is shown below.
Layer state after stamping layers
- Select Lines Based on Color Range: On the merged layer, use Select>Color Range from the menu, sample the line colors, and adjust the fuzziness. You can turn on selection preview set to "Quick Mask" mode, where red areas indicate parts to be removed. Ensure necessary line parts are preserved before confirming.
Adjust the color range, use the eyedropper tool to add and subtract lines and background, and adjust color tolerance to keep the desired line range
Create a mask from the line selection, now the image contains only the line content.
Create a mask from the obtained line selection, now only lines remain in the image
- Make Lines Clearer: Use Image>Adjustments>Hue/Saturation on the layer (not the mask) (shortcut Ctrl+U, Command+U on Mac), open the Hue/Saturation panel, and move the Lightness slider to the leftmost position (-100). Now you can see clear line effects, as shown below.
The effect of setting Lightness to -100 in the Hue/Saturation panel.
- Export Line Art: Now we can export the clear line art as a PNG format. The effect of this image against a white background is shown below.
The effect of the exported clean line art
3. Vectorizing Black and White Line Art
I used Adobe Illustrator (AI) to vectorize the line art. After importing the line art PNG image, use Object>Image Trace from the menu bar, and you can quickly obtain a vector image, as shown below.
The image after tracing in AI
When zoomed in, you can see the vectorized details.
The vectorized line art image
Export the traced image as SVG format, compared with the original color draft.
Comparison between vectorized line art and original color draft