def load_obj(obj): with open(obj, 'rb') as f: model = binvox.read_as_3d_array(f) model = model.data#.astype(np.uint8)*255 #print model[210:220,210:220,128] #print model.sum() #model2 = np.zeros((N,N,Nz)) #model = cloadobj.resize(np.array(model).astype(np.float32),N,Nz) #print model[210:220,210:220,128] #print model.sum() #model2 = ndimage.filters.gaussian_filter(model2,sigma =0.05) #r = 20 #r2 = 12 #r3 = 8 # c = scipy.ndimage.binary_closing(model2,structure=np.ones((r,r,r))).astype(np.uint8) #d = scipy.ndimage.binary_dilation(model2,structure=struct(r2)).astype(np.uint8) #e = scipy.ndimage.binary_erosion(d,structure=struct(r3)).astype(np.uint8) return model
def __init__(self, filename): with open(filename, 'rb') as f: model = binvox.read_as_3d_array(f) self.data = model.data.astype(np.uint8) self.points = [] self.dim = model.dims[0] self.indices = np.where(self.data == 1) total = self.data.sum() translate = (self.dim - 1) * 0.5 for i in range(total): x = self.indices[0][i] - translate y = self.indices[1][i] - translate z = self.indices[2][i] - translate point = [x, y, z] self.points.append(point)
def read_binvox(fname): with open(fname, 'rb') as f: model = binvox.read_as_3d_array(f) data = vox2tanh(model.data.astype(np.float32)) return data
def read_binvox(path): with open(path + ".binvox", 'rb') as f: m = binvox.read_as_3d_array(f).data return m
def read_binvox(filename): with open(filename, 'rb') as f: model = binvox.read_as_3d_array(f) data = model.data.astype(np.float32) return np.expand_dims(data, -1)
# -*- coding: utf-8 -*- """ Created on Wed May 22 14:45:36 2019 @author: Sooram Kang """ import os import numpy as np import binvox X = [] examples_dir = 'C:\\Users\\CHANG\\PycharmProjects\\3dCNN\\DCGAN\\modelnet\\bed\\bed_binvox\\' for example in os.listdir(examples_dir): if 'binvox' in example: with open(os.path.join(examples_dir, example), 'rb') as file: data = np.int32(binvox.read_as_3d_array(file).data) # padded_data = np.pad(data, 3, 'constant') X.append(data) np.savez_compressed('modelnet10_bed.npz', X_train=X)
def read_binvox(fname): with open(fname, 'rb') as f: model = binvox.read_as_3d_array(f) model = (model.data.astype(np.float32) - 0.5) / 0.5 return model
def read_binvox(fn): with open(fn, 'rb') as f: model = binvox.read_as_3d_array(f) return model.data.astype(np.float32)