# A Voxel Generator Based on Autoencoder
## 3 VoxGen  
The VoxGen voxel generator consists of an encoder and a decoder. It generates the output voxel for an input image as shown in Figure 1.  
The first step is data preprocessing, which adapts the size of the input image to 128 \(\times\) 128 and then transforms the color image into a gray image by calling the cvtColor() function of OpenCV [28] with the parameter of COLOR_BGR2 GRAY. Finally, it normalizes the gray value to be between 0 and 1. In this paper, we use a 3D dataset ShapeNet that provides multiple-view color images to train VoxGen while it generates a 3D voxel model using only a single image. Grayscale images require only one-third of the storage space of color images. To reduce the computation cost, VoxGen adopts one channel in its encoder and decoder, like V3 DOR-VE. The second step is to extract the features of the preprocessed input image and then transform them into latent variables through the encoder. Currently, VoxGen has two encoder structures. One was constructed by modifying VGG16 and the other by modifying ResNet, including ResNet18, 34, and 50. In the modified-VGG16 encoder, as shown in Figure 2, the front part is composed of five convolution blocks, each ending with a max pooling layer (2 \(\times\) 2, stride = 2). These five convolution blocks are (3 \(\times\) 3, 64, stride = 2) \(\times\) 2, (3 \(\times\) 3, 128, stride = 2) \(\times\) 2, (3 \(\times\) 3, 256, stride = 2) \(\times\) 3, (3 \(\times\) 3, 512, stride = 2) \(\times\) 3, and (3 \(\times\) 3, 512, stride = 2) \(\times\) 3. The rear part consists of a flattened layer and two fully connected layers of 1 \(\times\) 8192 and 1 \(\times\) 4096; it is used to generate the output, which is reshaped as a 1 \(\times\) 1 \(\times\) 1 \(\times\) 4096 latent variable. As shown in Figure 3, in the modified-ResNet18 encoder, the front part has a convolution layer (7 \(\times\) 7, 64, stride = 2) and a max pooling layer (3 \(\times\) 3, stride = 2) at the beginning, and four different-sized convolution layer blocks, i.e., \( \begin{bmatrix}3\times 3,\ 64\\ 3\times 3,\ 64\end{bmatrix} \times 2\), \( \begin{bmatrix}3\times 3,\ 128\\ 3\times 3,\ 128\end{bmatrix} \times 2\), \( \begin{bmatrix}3\times 3,\ 512\\ 3\times 3,\ 512\end{bmatrix} \times 2\), after the max pooling layer. The rear part is as same as in the VGG16-modified encoder. As for the modified ResNet34 and ResNet50 encoders, their architectures are similar to that of the modified ResNet18 encoder. The difference is that the four different-sized convolution blocks of the ResNet34 are \( \begin{bmatrix}3\times 3,\ 64\\ 3\times 3,\ 64\end{bmatrix} \times 3\),  
Figure 1: Process of generating the 3D voxel model for the input image. \[ \begin{bmatrix}3\times 3,\ 128\\ 3\times 3,\ 128\end{bmatrix} \times 4,\ \begin{bmatrix}3\times 3,\ 256\\ 3\times 3,\ 256\end{bmatrix} \times 6,\ \text{and}\ \begin{bmatrix}3\times 3,\ 512 \\ 3\times 3,\ 512\end{bmatrix} \times 3,\ \text{while those of ResNet50 are}\\ \left[ \begin{array}{cc}1\times 1,\ 64\\ 3\times 3,\ 64\\ 1\times 1,\ 256\end{array} \right]\times 3,\ \begin{bmatrix}1\times 1,\ 128 \\ 3\times 3,\ 128\\ 1\times 1,\ 512\end{bmatrix} \times 4,\ \begin{bmatrix}1\times 1,\ 256\\ 3\times 3,\ 256\\ 1\times 1,\ 1024\end{bmatrix} \times 6,\text{and}\ \begin{bmatrix}1\times 1,\ 512 \\ 3\times 3,\ 512\\ 1\times 1,\ 2048\end{bmatrix} \times 3.\]  
It is worth mentioning that the original VGG16 has three fully connected layers; their sizes are 1 \(\times\) 4096, 1 \(\times\) 4096, and 1 \(\times\) 1000. By contrast, the original ResNet18, 34, and 50 have a global average pooling layer and one 1 \(\times\) 1000 fully connected layer. Based on our experiments, the depth and width of the fully connected network of the original VGG16 and ResNet were not suitable to achieve sufficient accuracy of the generated 3D voxel models. Consequently, we increased the depth and width of the fully connected networks in the VGG16-encoder and ResNet18, 34, 50-modified encoders.