CUDA加速弹性形变等图像增广(医疗图像)

编程入门 行业动态 更新时间:2024-10-05 23:23:39

CUDA加速弹性形变等<a href=https://www.elefans.com/category/jswz/34/1771430.html style=图像增广(医疗图像)"/>

CUDA加速弹性形变等图像增广(医疗图像)

Cuda_Spatial_Deform

本文推出一套使用CUDA加速图像空间形变计算,使用GPU并行计算加速计算,尤其在弹性形变上表现非常突出,在图像增广中帮助很大,尤其在医疗图像领域比较常用,代码地址

A fast tool to do image augmentation by CUDA on GPU(especially elastic deform), can be helpful to research on Medical Image.

Motivation

  • When the size of image is too large, it will take a lot of time(much more than forward and backward computation like U_Net), especially for 3D image(like CT).
  • Elastic deformation on CPU is too slow.
  • Doing Sptial_Deform by muti-processing consumes of too much CPU resources, whitch most GPU servers(like 32 cores with 4 gpus) can not afford.

Implementation Overview

  • Doing Spation_Deform on GPU instead of CPU, greatly saving CPU resources.
  • Very Fast, speed up 25x at rotation, 45x at elastic_deform.
  • Support many types of spatial deform: flip, rotate, scale, translate, elastic_deform.
  • Support many rules of map_coordinates: mirror, constant, reflect, wrap, nearest.
  • Doing Spatial_Deform by doing calculates on coordinates, all transformations get combined before they are applied to the image
  • Implement map_coordinates by linear interpolation.
  • Unit test pass when over 99% pixels has L1_loss < 1e-3.
  • Flexible with coordinates, users can fetch them form CUDA and do cubic interpolation at CPU by scipy.map_coordinates(order = 3)

Speed Test

Test on 3D image , shape = [48, 240, 240]

Time(ms)RotateElastic
CUDA1440
CPU3041821

How to Use

CMake

cd cuda_backend
cmake -D CUDA_TOOLKIT_ROOT_DIR=/path/to/cuda .
make -j8

Set_Config

# Import cuda_spation_deform Handle
from cuda_spatial_deform import Cuda_Spatial_Deform# Init Handle
cuda_handle = Cuda_Spatial_Deform(array_image.shape, mode="constant")
'''Shape: cuda_backend will malloc according to shapeRGB: bool (Only Support 2D-RGB)mode: The rules of map_coordinates. Reference  to  .ndimage.map_coordinates.htmlcval: default is 0.0. Only be useful when mode == 'constant'id_gpu: choose the number of GPU
'''# Choose your Rules of spatial_deform# cuda_handle.scale(0.5)
# cuda_handle.flip(do_y=True, do_x=True, do_z=True)
# cuda_handle.translate(100, 100, 20)
# cuda_handle.rotate(0.75 * np.pi, 0.75 * np.pi, 0.75 * np.pi)
cuda_handle.elastic(sigma=12., alpha=200., mode='constant')
cuda_handle.end_flag()

DO augmentation

# The shape must be equal to cuda_handle.shape
array_image = load_np_array(data_pth)
output = cuda_handle.augment(array_image)
# done_list will list the translations actually done
done_list = output[1]
output_array = output[0]

Example_Image

Flip

Rotate

Translate

Scale

Elastic_Deform

Reference

batchgenerators

scipy

The elastic deformation approach is described in

  • Ronneberger, Fischer, and Brox, “U-Net: Convolutional Networks for Biomedical
    Image Segmentation” (.04597)
  • Çiçek et al., “3D U-Net: Learning Dense Volumetric
    Segmentation from Sparse Annotation” (.06650)

更多推荐

CUDA加速弹性形变等图像增广(医疗图像)

本文发布于:2024-02-07 03:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1752724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   弹性   医疗   CUDA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!