voxels | Voxels Library - C library for voxel manipulation | Computer Vision library
kandi X-RAY | voxels Summary
kandi X-RAY | voxels Summary
Voxel-based surfaces allow for more freedom than usual polygon-based ones. The major advantages of such a representation can be summarized as follows:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of voxels
voxels Key Features
voxels Examples and Code Snippets
Community Discussions
Trending Discussions on voxels
QUESTION
I would like to find minimum distance of each voxel to a boundary element in a binary image in which the z voxel size is different from the xy voxel size. This is to say that a single voxel represents a 225x110x110 (zyx) nm volume.
Normally, I would do something with scipy.ndimage.morphology.distance_transform_edt (https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.morphology.distance_transform_edt.html) but this gives the assume that isotropic sizes of the voxel:
...ANSWER
Answered 2021-Jun-15 at 02:32Normally, I would do something with scipy.ndimage.morphology.distance_transform_edt but this gives the assume that isotropic sizes of the voxel:
It does no such thing! You are looking for the sampling=
parameter. From the latest version of the docs:
Spacing of elements along each dimension. If a sequence, must be of length equal to the input rank; if a single number, this is used for all axes. If not specified, a grid spacing of unity is implied.
The wording "sampling" or "spacing" is probably a bit mysterious if you think of pixels as little squares/cubes, and that is probably why you missed it. In most situations, it is better to think of pixels as point samples on a grid, with fixed spacing between samples. I recommend Alvy Ray's a pixel is not a little square for a better understanding of this terminology.
QUESTION
I would like to voxelise a .stl file and write it into an np.array. The resolution of the voxels should be adjustable. Here is my code for this:
...ANSWER
Answered 2021-May-25 at 09:00If anyone ever has the same problem and is looking for a solution: This project worked for me: GitHub: stl-to-voxel
The model is then also filled. If the maximum dimension is known, you can determine the exact voxel size via the resolution.
Here is some code:
QUESTION
I'm trying to generate a .vox represantation of my Prison Architect save file. I'm using a library called voxelfuse to generate the voxels and for some reason the union() method gives me a can only concatenate str (not "int") to str
Here's my code:
ANSWER
Answered 2021-May-14 at 13:38Considering tiles
is read from a file I believe the problem may be that tile['x']
and tile['y']
are strings and not integers. Try to transform them before passing them as arguments:
QUESTION
Is there any good way to downsample voxels grid in OpenVDB?
For example I have grid 8x8x8 with voxel size - 1.0, and I want to get grid 4x4x4 with voxel size - 2.0:
each voxel of new grid is some interpolation of original voxels, e. g. [0,0,0] voxel of new grid is average value of [0,0,0]-[1,1,1] (8 voxels) of original grid)
P.S. There is way to do it manually but I bet openvdb has its own implementation
...ANSWER
Answered 2021-May-12 at 11:43The thing I was looking for is resampleToMatch
QUESTION
I am trying to implement marching cubes into my game, and so far I have set up a system for drawing triangles with four points in world space. I have got the system working where I set the points, but then when I draw the two triangles to make it a mesh, it only draws one, but I set up a print()
statement, and it shows that 2 triangles are drawn each time, so that is normal. I can't figure out what I need to do. Here is my code, and comment on this post if you need any more pics/code:
ANSWER
Answered 2021-May-08 at 21:29I'm pretty sure your issue here is order.
Unity uses a clockwise winding order. This means that
if you provide the triangles in clockwise order the normal will face towards you and you will see the triangle.
if you provide the triangle in counter-clockwise order the normal will face away from you and you will not see the triangle.
Now looking at your code (at least as far as I can tell) your vertices look somewhat like
QUESTION
I have a stack of 1000 images with more than 120k objects. After running a Connected Component Algorithm in a third party software, I obtained a coloured image, in which each connected object has a label, a color and an ID value assigned.
I need to extract the list of the voxels coordinates that make up each of the objects.
I have written a Python code to extract this information but it is extremely slow since it processes ~30 labels/min. Therefore, it would take more than 2 days to process the entire scan in the best scenario.
After converting the stack into a 3D Numpy array (img_stack_numpy
), here is the main part of the code:
ANSWER
Answered 2021-Apr-15 at 23:17The main issue with the current code lies in the line np.where(img_stack_np == label)
. Indeed, it iterate over the 700 * 700 * 1000 = 490,000,000
values of img_stack_np
for the 120,000 values of label_list
resulting in 490,000,000 * 120,000 = 58,800,000,000,000
values to check.
You do not need to iterate over img_stack_np
for every label. What you need is to classify the "voxels" by their value (ie. label). You can do that using a custom sort:
- first, store the position of each voxel in an array with the label;
- then, do a key-value sort where the label is the key and the voxel position is the value;
- then, iterate through the sorted items to group them by label (or use the less efficient
np.unique
for sake of simplicity); - finally store the position of each group in the final dict.
For sake of simplicity and to limit the memory usage, an index-based sort can also be used in replacement to the key-value sort. This can be done with argsort
. Here is an example code:
QUESTION
I am working with volume data in raw format. I think that it is basically a 3D matrix of voxels that I want to load into a 3D array. I have no experience with this, and I’m unable to find much information on how it is done. My main problem is that I don’t really understand what the data represents.
So what I’m asking really if anybody can help me to understand the data and load it into a 3D array with Java.
...ANSWER
Answered 2021-Apr-15 at 01:38You're correct in thinking the first thing you need to do is understand the data. Here's a good explanation of what you're likely dealing with: https://support.echoview.com/WebHelp/Reference/File_formats/Export_file_formats/Volume_data_set_file_formats.htm#data_file
The .raw file probably contains a sequence of unsigned 8 bit integers. It's hard to say exactly without seeing the file (i.e. does it have a header, what is the matrix size, etc.)
Here's an answer that shows one method of converting from a 3D vector to a volume index and back in Java: https://stackoverflow.com/a/34363187/1973135. You'll need to know the actual dimension of the matrix to get this to work.
QUESTION
I'm trying to build a voxel engine, and to do this I have to create hundreds of thousands of voxels, and I was hoping I could use instanced rendering. However, on rendering, the shape is completely disfigured, and not the expected cube shape:
And with several voxels:
This is what my code looks like:
chunk.hpp
...ANSWER
Answered 2021-Mar-15 at 02:05The last time, you used the geometry also as transformation matrices. This time, you use the transformation matrices also as geometry.
Here you fill VBO
with the vertex data:
QUESTION
I'm trying to build a voxel engine, and to do this I have to create hundreds of thousands of voxels, and I was hoping I could use instanced rendering. However, the drawing is very unexpected. I'm primarily following the LearnOpenGL guide.
When rendering each voxel individually, the program works fine:
However, when using instanced rendering...
Another angle...
I'm trying to render the voxels in a big chunk, so this is what my code looks like:
voxel.hpp
...ANSWER
Answered 2021-Mar-14 at 21:19Your VBO setup doesn't make the slightest sense. You set up your per-instance transformation matrix to use the same data as your geometry in Voxel::generateElement()
.
You later upload all your transformation matrixes into a separate VBO, but the attribute pointers still point to the geometry VBO. YOu need to move the attribute setup for the instanced attribute out of Voxel::generateElement()
and into Chunk::Chunk()
so you can tell it to use that VBO as source for the model matrices.
QUESTION
I am trying to have a gameobject in unity react with sound if another object is inside it. I want the gameobject to use the entering objects location to then see what voxel is closest and then play audio based on the voxel intensity/colour. Does anyone have any ideas? I am working with a dataset that is 512x256x512 voxels. I want it to work if the object is resized as well. Any help is much appreciated :).
The dataset I'm working with is a 3d .mhd medical scan of a body. Here is how the texture is added to the renderer on start:
...ANSWER
Answered 2021-Mar-13 at 12:11You can try setting up a large amount of box colliders and the OnTriggerEnter() function running on each. But a much better solution is to sort your array of voxels and then use simple math to clamp the moving objects position vector to ints and do some maths to map the vector to an index in the array. For example the vector (0,0,0) could map to voxels[0]. Then just fetch that voxels properties as you like. For a voxel application this would be a much needed faster calculation than colliders.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install voxels
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page