Skip to main content

An efficient volume rotation algorithm based on Cupy.

Project description

rotate_volume

An efficient volume rotation algorithm based on Cupy.

GitHub repo: https://github.com/GGN-2015/rotate_volume

Installation

pip install rotate_volume

Usage

import cupy as cp
from rotate_volume import rotate_volume, create_rotation_matrix

# Create test volume data, replace the data with your own 3d cupy array
# in volume data, zero means empty, one means valid voxel
test_volume = cp.ones((20, 20, 20), dtype=cp.float32)

# make rotation matrix
rotation_x   = create_rotation_matrix('x', angle_deg=10)
rotation_y   = create_rotation_matrix('y', angle_deg=20)
rotation_z   = create_rotation_matrix('z', angle_deg=30)
rotation_all = rotation_z @ rotation_y @ rotation_x

# Rotate
rotated_cropped = rotate_volume(test_volume, rotation_all)

# Verify results
print(f"Original data shape: {test_volume.shape}")
print(f"Rotated and cropped data shape: {rotated_cropped.shape}")
print(f"Original valid data count: {cp.count_nonzero(test_volume >= 0.5)}")
print(f"Rotated and cropped valid data count: {cp.count_nonzero(rotated_cropped >= 0.5)}")

# If you want to visualize the 3d data, you can use `visualize_volume`
# Use `pip install visualize_volume` to install it before using it
from visualize_volume import visualize_volume
visualize_volume(cp.asnumpy(rotated_cropped))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotate_volume-0.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotate_volume-0.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file rotate_volume-0.0.0.tar.gz.

File metadata

  • Download URL: rotate_volume-0.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.17.7-aosc-main

File hashes

Hashes for rotate_volume-0.0.0.tar.gz
Algorithm Hash digest
SHA256 557b188d735fc2f1cd575095247f150d7bd3acdab74cad7df3b4b1974e1ce17b
MD5 804a64f121483b62c742e95c1af0a6c1
BLAKE2b-256 ad71c73b3077d8c3d9cb2ffc706728f150b3c70c6318f8c98e89e04746761b9a

See more details on using hashes here.

File details

Details for the file rotate_volume-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: rotate_volume-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.18 Linux/6.17.7-aosc-main

File hashes

Hashes for rotate_volume-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae0b8d7f4d1be79f45d0f6bb07999d059f459fa541effa3d92ccf54cbfce464c
MD5 9adcf52b25d9c983c5d78663f20cd4f4
BLAKE2b-256 d6cf2c572b7c43b5811b8bd5b43b568cb95bbb86fdab4f875a734cd3ed83fcd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page