• Stars
    star
    187
  • Rank 205,227 (Top 5 %)
  • Language
    C
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Marching cubes implementation for PyTorch environment.

torchmcubes: marching cubes for PyTorch

Marching cubes for PyTorch environment. Backend is implemented with C++ and CUDA.

Install

pip install git+https://github.com/tatsy/torchmcubes.git

Build only

# After cloning this repo...
python setup.py build_ext -i

Usage

See mcubes.py for the detail.

import numpy as np
import open3d as o3d

import torch
from torchmcubes import marching_cubes, grid_interp

# Grid data
N = 128
x, y, z = np.mgrid[:N, :N, :N]
x = (x / N).astype('float32')
y = (y / N).astype('float32')
z = (z / N).astype('float32')

# Implicit function (metaball)
f0 = (x - 0.35) ** 2 + (y - 0.35) ** 2 + (z - 0.35) ** 2
f1 = (x - 0.65) ** 2 + (y - 0.65) ** 2 + (z - 0.65) ** 2
u = 1.0 / f0 + 1.0 / f1
rgb = np.stack((x, y, z), axis=-1)
rgb = np.transpose(rgb, axes=(3, 2, 1, 0)).copy()

# Test
u = torch.from_numpy(u).cuda()
rgb = torch.from_numpy(rgb).cuda()
verts, faces = marching_cubes(u, 15.0)
colrs = grid_interp(rgb, verts)

verts = verts.cpu().numpy()
faces = faces.cpu().numpy()
colrs = colrs.cpu().numpy()

# Use Open3D for visualization
mesh = o3d.geometry.TriangleMesh()
mesh.vertices = o3d.utility.Vector3dVector(verts)
mesh.triangles = o3d.utility.Vector3iVector(faces)
mesh.vertex_colors = o3d.utility.Vector3dVector(colrs)
wire = o3d.geometry.LineSet.create_from_triangle_mesh(mesh)
o3d.visualization.draw_geometries([mesh, wire], window_name='Marching cubes (CUDA)')

Screen shot

metaball.png

Copyright

MIT License 2019-2021 (c) Tatsuya Yatagawa

More Repositories

1

keras-generative

Deep generative networks, coded with Keras.
Python
122
star
2

tinymesh

TinyMesh is a light-weight mesh processing library in C/C++.
C++
82
star
3

normalizing-flows-pytorch

PyTorch implementations of normalizing flow and its variants.
Python
71
star
4

LightField

Light field viewer and virtual light field camera
C++
55
star
5

lime

lime (Library for Image Editing)
C++
50
star
6

markdown-it-imsize

markdown-it plugin for size-specified image markups.
JavaScript
46
star
7

ImageProcessing

Image processing programs
C++
45
star
8

vscode-3d-preview

VSCode 3D Data Previewer
JavaScript
36
star
9

educnn

Simple implementation of CNN (convolutional neural network) with precise-comments.
C++
36
star
10

hydra

Python HDR image processing library
Python
28
star
11

tf-generative

TensorFlow implementation of deep generative models, such as VAEs and GANs.
Python
26
star
12

ColorConstancy

Implementation of several algorithms for color constancy
C++
25
star
13

qt5-shadow-maps

Shadow mapping implementation with Qt5 and OpenGL
C++
25
star
14

OpenGLCourseJP

General OpenGL Course in Japanese.
C
23
star
15

spica

spica is a cross-platform renderer
C++
21
star
16

FastTranslucentShader

Fast translucent object rendering with GLSL.
C++
21
star
17

L0Denoising

Implementation of the paper "Mesh Denoising via L0 Optimization"
C++
19
star
18

SpinnakerCamera

Easy-to-use C++ wrapper for FLIR's Spinnaker SDK
C++
13
star
19

QtOpenGLMousePick

Sample program for OpenGL mouse picking.
C++
11
star
20

markdown-it-responsive

markdown-it-plugin for responsive images
JavaScript
11
star
21

opengl-raytracer

OpenGL/GLSL ray tracing engine
C
8
star
22

libcbct

Cone-beam CT reconstruction library.
C++
8
star
23

MicrofacetDistribution

Simple rendering program using microfacet distribution for glossy surfaces.
C
7
star
24

bssrdf-estimate

Implementation of "BSSRDF Estimation from Single Images" by Munoz et al. (Eurographics 2011)
Python
6
star
25

tatsy-pppm

Physically-based ray tracer for "Ray Tracing Capm 3!!!"
C++
6
star
26

DiffusionApprox

Diffusion approximation for Computer Graphics
C++
6
star
27

BagOfFeatures

bag of features implementation
C++
5
star
28

QtOpenGLTutorials

Sample program of OpenGL with Qt.
C++
5
star
29

linsss-vulkan

Official implementation of LinSSS paper using Vulkan
C++
5
star
30

VulkanExamples

Vulkan examples.
C++
3
star
31

programming-for-beginners

C++ and Python programming for intermediate learners
Jupyter Notebook
3
star
32

CompareShadowMaps

Compares various shadow map algorithms.
C++
2
star
33

docker-ubuntu-cxx

Docker image for CXX build environment
2
star
34

node-diary

A simple diary or notebook tool using Node.js and socke.io
JavaScript
1
star
35

NPRShading

C++
1
star
36

GLAA

OpenGL antialiasing examples.
C++
1
star
37

MinimizeFunction

Python
1
star
38

MeshVolume

C++
1
star
39

WebGLChess

TypeScript
1
star
40

MVSNet

Python
1
star
41

deep-face-intrin

Face intrinsic imaging with deep convolutional network.
Python
1
star
42

PptLatexEditor

C#
1
star
43

1284-sds-ml-advanced

Jupyter Notebook
1
star
44

LinearAlgebra

C++
1
star