- Generative Adversarial Networks Projects
- Kailash Ahirwar
- 240字
- 2021-07-02 13:38:52
Loading and visualizing a 3D image
The 3D ShapeNets dataset contains Computer-aided design (CAD) models of different object categories, which are in the .mat file format. We will convert these .mat files to NumPy ndarrays. We will also visualize a 3D image to get a visual understanding of the dataset.
Execute the following code to load a 3D image from a .mat file:
- Use the loadmat() function from scipy to retrieve the voxels. The code is as follows:
import scipy.io as io
voxels = io.loadmat("path to .mat file")['instance']
- The shape of the loaded 3D image is 30x30x30. Our network requires images of shape 64x64x64. We will use NumPy's pad() method to increase the size of the 3D image to 32x32x32:
import numpy as np
voxels = np.pad(voxels, (1, 1), 'constant', constant_values=(0, 0))
The pad() method takes four parameters, which are the ndarray of the actual voxels, the number of values that need to be padded to the edges of each axes, the mode values (constant), and the constant_values that are to be padded.
- Then, use the zoom() function from the scipy.ndimage module to convert the 3D image to a 3D image with dimensions of 64x64x64.
import scipy.ndimage as nd
voxels = nd.zoom(voxels, (2, 2, 2), mode='constant', order=0)
Our network requires images to be shaped 64x64x64, which is why we converted our 3D images to this shape.
推薦閱讀
- 自動(dòng)控制工程設(shè)計(jì)入門
- 工業(yè)機(jī)器人技術(shù)及應(yīng)用
- 7天精通Dreamweaver CS5網(wǎng)頁設(shè)計(jì)與制作
- 機(jī)艙監(jiān)測與主機(jī)遙控
- 21天學(xué)通ASP.NET
- Cloudera Administration Handbook
- 單片機(jī)C語言應(yīng)用100例
- PLC與變頻技術(shù)應(yīng)用
- 單片機(jī)技術(shù)項(xiàng)目化原理與實(shí)訓(xùn)
- Mastering Text Mining with R
- 機(jī)器人制作入門(第4版)
- 菜鳥起飛電腦組裝·維護(hù)與故障排查
- Deep Learning Essentials
- 機(jī)器人剛?cè)狁詈蟿?dòng)力學(xué)
- Mastercam X5應(yīng)用技能基本功特訓(xùn)