pyfast 4.12.0__cp36-abi3-macosx_10_13_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fast/README.md +41 -0
- fast/__init__.py +22 -0
- fast/bin/UFFviewer +0 -0
- fast/bin/fast_configuration.txt +14 -0
- fast/bin/runPipeline +0 -0
- fast/bin/systemCheck +0 -0
- fast/doc/bright-plotting-style.ini +66 -0
- fast/doc/dark-plotting-style.ini +66 -0
- fast/doc/fonts/UFL.txt +96 -0
- fast/doc/fonts/Ubuntu-Bold.ttf +0 -0
- fast/doc/fonts/Ubuntu-BoldItalic.ttf +0 -0
- fast/doc/fonts/Ubuntu-Italic.ttf +0 -0
- fast/doc/fonts/Ubuntu-Light.ttf +0 -0
- fast/doc/fonts/Ubuntu-LightItalic.ttf +0 -0
- fast/doc/fonts/Ubuntu-Medium.ttf +0 -0
- fast/doc/fonts/Ubuntu-MediumItalic.ttf +0 -0
- fast/doc/fonts/Ubuntu-Regular.ttf +0 -0
- fast/doc/fonts/UbuntuMono-Bold.ttf +0 -0
- fast/doc/fonts/UbuntuMono-BoldItalic.ttf +0 -0
- fast/doc/fonts/UbuntuMono-Italic.ttf +0 -0
- fast/doc/fonts/UbuntuMono-Regular.ttf +0 -0
- fast/doc/images/FAST_logo_square.png +0 -0
- fast/doc/images/fast_icon.ico +0 -0
- fast/doc/images/fast_icon.png +0 -0
- fast/entry_points.py +14 -0
- fast/fast.py +19961 -0
- fast/kernels/Algorithms/AirwaySegmentation/AirwaySegmentation.cl +85 -0
- fast/kernels/Algorithms/ApplyColormap/ApplyColormap.cl +146 -0
- fast/kernels/Algorithms/BinaryThresholding/BinaryThresholding2D.cl +61 -0
- fast/kernels/Algorithms/BinaryThresholding/BinaryThresholding3D.cl +61 -0
- fast/kernels/Algorithms/BlockMatching/BlockMatching.cl +257 -0
- fast/kernels/Algorithms/CenterlineExtraction/CenterlineExtraction.cl +153 -0
- fast/kernels/Algorithms/CoherentPointDrift/CoherentPointDrift.cl +0 -0
- fast/kernels/Algorithms/Color/ColorToGrayscale.cl +22 -0
- fast/kernels/Algorithms/Color/GrayscaleToColor.cl +19 -0
- fast/kernels/Algorithms/GaussianSmoothing/GaussianSmoothing2D.cl +35 -0
- fast/kernels/Algorithms/GaussianSmoothing/GaussianSmoothing3D.cl +75 -0
- fast/kernels/Algorithms/GradientVectorFlow/EulerGradientVectorFlow.cl +174 -0
- fast/kernels/Algorithms/GradientVectorFlow/MultigridGradientVectorFlow.cl +407 -0
- fast/kernels/Algorithms/HounsefieldConverter/HounsefieldConverter.cl +22 -0
- fast/kernels/Algorithms/ImageAdd/ImageAdd.cl +79 -0
- fast/kernels/Algorithms/ImageCaster/ImageCaster.cl +38 -0
- fast/kernels/Algorithms/ImageChannelConverter/ImageChannelConverter.cl +121 -0
- fast/kernels/Algorithms/ImageFlipper/ImageFlipper2D.cl +23 -0
- fast/kernels/Algorithms/ImageFlipper/ImageFlipper3D.cl +51 -0
- fast/kernels/Algorithms/ImageGradient/ImageGradient.cl +71 -0
- fast/kernels/Algorithms/ImageInverter/ImageInverter.cl +30 -0
- fast/kernels/Algorithms/ImageMultiply/ImageMultiply.cl +79 -0
- fast/kernels/Algorithms/ImagePatch/PatchStitcher2D.cl +22 -0
- fast/kernels/Algorithms/ImagePatch/PatchStitcher3D.cl +95 -0
- fast/kernels/Algorithms/ImageResampler/ImageResampler2D.cl +40 -0
- fast/kernels/Algorithms/ImageResampler/ImageResampler3D.cl +32 -0
- fast/kernels/Algorithms/ImageResizer/ImageResizer.cl +134 -0
- fast/kernels/Algorithms/ImageSharpening/ImageSharpening.cl +47 -0
- fast/kernels/Algorithms/ImageSlicer/ImageSlicer.cl +77 -0
- fast/kernels/Algorithms/ImageTransposer/ImageTransposer2D.cl +16 -0
- fast/kernels/Algorithms/ImageTransposer/ImageTransposer3D.cl +45 -0
- fast/kernels/Algorithms/IntensityClipping/IntensityClipping2D.cl +19 -0
- fast/kernels/Algorithms/IntensityClipping/IntensityClipping3D.cl +20 -0
- fast/kernels/Algorithms/IntensityNormalization/IntensityNormalization.cl +85 -0
- fast/kernels/Algorithms/IntensityNormalization/ZeroMeanUnitVariance.cl +76 -0
- fast/kernels/Algorithms/KalmanFilterModelSegmentation/AppearanceModels/RidgeEdge/RidgeEdgeModel.cl +81 -0
- fast/kernels/Algorithms/LabelModifier/LabelModifier.cl +20 -0
- fast/kernels/Algorithms/LaplacianOfGaussian/LaplacianOfGaussian2D.cl +27 -0
- fast/kernels/Algorithms/LevelSet/LevelSetSegmentation.cl +132 -0
- fast/kernels/Algorithms/LungSegmentation/LungSegmentation.cl +22 -0
- fast/kernels/Algorithms/MeshToSegmentation/MeshToSegmentation.cl +184 -0
- fast/kernels/Algorithms/Morphology/Dilation.cl +56 -0
- fast/kernels/Algorithms/Morphology/Erosion.cl +64 -0
- fast/kernels/Algorithms/NeuralNetwork/NeuralNetwork.cl +122 -0
- fast/kernels/Algorithms/NeuralNetwork/VertexTensorToSegmentation.cl +13 -0
- fast/kernels/Algorithms/NonLocalMeans/NonLocalMeans2D.cl +94 -0
- fast/kernels/Algorithms/SeededRegionGrowing/SeededRegionGrowing2D.cl +57 -0
- fast/kernels/Algorithms/SeededRegionGrowing/SeededRegionGrowing3D.cl +58 -0
- fast/kernels/Algorithms/Skeletonization/Skeletonization2D.cl +77 -0
- fast/kernels/Algorithms/SurfaceExtraction/SurfaceExtraction.cl +519 -0
- fast/kernels/Algorithms/SurfaceExtraction/SurfaceExtraction_no_3d_write.cl +739 -0
- fast/kernels/Algorithms/TemporalSmoothing/ImageMovingAverage.cl +66 -0
- fast/kernels/Algorithms/TemporalSmoothing/ImageWeightedMovingAverage.cl +74 -0
- fast/kernels/Algorithms/TissueSegmentation/TissueSegmentation.cl +18 -0
- fast/kernels/Algorithms/TubeSegmentationAndCenterlineExtraction/InverseGradientSegmentation.cl +203 -0
- fast/kernels/Algorithms/TubeSegmentationAndCenterlineExtraction/TubeSegmentationAndCenterlineExtraction.cl +566 -0
- fast/kernels/Algorithms/Ultrasound/EnvelopeAndLogCompressor.cl +45 -0
- fast/kernels/Algorithms/Ultrasound/ScanConverter.cl +76 -0
- fast/kernels/Algorithms/UltrasoundImageCropper/UltrasoundImageCropper.cl +31 -0
- fast/kernels/Algorithms/UltrasoundImageEnhancement/UltrasoundImageEnhancement.cl +27 -0
- fast/kernels/Algorithms/VectorMedianFilter/VectorMedianFilter.cl +31 -0
- fast/kernels/ImageFill.cl +30 -0
- fast/kernels/ImageMinMax.cl +196 -0
- fast/kernels/ImageSum.cl +170 -0
- fast/kernels/Tests/Algorithms/DoubleFilter.cl +7 -0
- fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.frag +8 -0
- fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.geom +69 -0
- fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.vert +17 -0
- fast/kernels/Visualization/HeatmapRenderer/HeatmapRenderer.cl +51 -0
- fast/kernels/Visualization/ImagePyramidRenderer/ImagePyramidRenderer.frag +11 -0
- fast/kernels/Visualization/ImagePyramidRenderer/ImagePyramidRenderer.vert +15 -0
- fast/kernels/Visualization/ImageRenderer/ImageRenderer.vert +15 -0
- fast/kernels/Visualization/ImageRenderer/ImageRendererFLOAT.frag +18 -0
- fast/kernels/Visualization/ImageRenderer/ImageRendererINT.frag +18 -0
- fast/kernels/Visualization/ImageRenderer/ImageRendererUINT.frag +18 -0
- fast/kernels/Visualization/LineRenderer/LineRenderer.frag +8 -0
- fast/kernels/Visualization/LineRenderer/LineRenderer.geom +35 -0
- fast/kernels/Visualization/LineRenderer/LineRenderer.vert +20 -0
- fast/kernels/Visualization/LineRenderer/LineRenderer3D.frag +8 -0
- fast/kernels/Visualization/LineRenderer/LineRenderer3D.vert +20 -0
- fast/kernels/Visualization/LineRenderer/LineRendererJoints.frag +15 -0
- fast/kernels/Visualization/LineRenderer/LineRendererJoints.vert +24 -0
- fast/kernels/Visualization/SegmentationLabelRenderer/SegmentationLabelRenderer.frag +11 -0
- fast/kernels/Visualization/SegmentationLabelRenderer/SegmentationLabelRenderer.vert +16 -0
- fast/kernels/Visualization/SegmentationRenderer/SegmentationPyramidRenderer.frag +53 -0
- fast/kernels/Visualization/SegmentationRenderer/SegmentationRenderer.frag +52 -0
- fast/kernels/Visualization/SegmentationRenderer/SegmentationRenderer.vert +15 -0
- fast/kernels/Visualization/TextRenderer/TextRenderer.frag +11 -0
- fast/kernels/Visualization/TextRenderer/TextRenderer.vert +20 -0
- fast/kernels/Visualization/TriangleRenderer/TriangleRenderer.frag +49 -0
- fast/kernels/Visualization/TriangleRenderer/TriangleRenderer.vert +35 -0
- fast/kernels/Visualization/VectorFieldRenderer/VectorFieldColorRenderer.cl +30 -0
- fast/kernels/Visualization/VertexRenderer/VertexRenderer.frag +14 -0
- fast/kernels/Visualization/VertexRenderer/VertexRenderer.vert +23 -0
- fast/kernels/Visualization/View.cl +10 -0
- fast/kernels/Visualization/VolumeRenderer/AlphaBlendingVolumeRenderer.cl +211 -0
- fast/kernels/Visualization/VolumeRenderer/MaximumIntensityProjection.cl +139 -0
- fast/kernels/Visualization/VolumeRenderer/ThresholdVolumeRenderer.cl +178 -0
- fast/lib/_fast.abi3.so +0 -0
- fast/lib/libFAST.4.dylib +0 -0
- fast/lib/libInferenceEngineONNXRuntime.dylib +0 -0
- fast/lib/libInferenceEngineOpenVINO.dylib +0 -0
- fast/lib/libInferenceEngineTensorFlow.dylib +0 -0
- fast/lib/libJKQTCommonSharedLib_Release.4.0.0.dylib +0 -0
- fast/lib/libJKQTFastPlotterSharedLib_Release.4.0.0.dylib +0 -0
- fast/lib/libJKQTMathTextSharedLib_Release.4.0.0.dylib +0 -0
- fast/lib/libJKQTPlotterSharedLib_Release.4.0.0.dylib +0 -0
- fast/lib/libOpenIGTLink.3.dylib +0 -0
- fast/lib/libQt5Core.5.dylib +0 -0
- fast/lib/libQt5DBus.5.dylib +0 -0
- fast/lib/libQt5Gui.5.dylib +0 -0
- fast/lib/libQt5Multimedia.5.dylib +0 -0
- fast/lib/libQt5MultimediaWidgets.5.dylib +0 -0
- fast/lib/libQt5Network.5.dylib +0 -0
- fast/lib/libQt5OpenGL.5.dylib +0 -0
- fast/lib/libQt5PrintSupport.5.dylib +0 -0
- fast/lib/libQt5SerialPort.5.dylib +0 -0
- fast/lib/libQt5Svg.5.dylib +0 -0
- fast/lib/libQt5Widgets.5.dylib +0 -0
- fast/lib/libQt5Xml.5.dylib +0 -0
- fast/lib/libbrotlicommon.1.dylib +0 -0
- fast/lib/libbrotlidec.1.dylib +0 -0
- fast/lib/libbrotlienc.1.dylib +0 -0
- fast/lib/libdcmdata.17.dylib +0 -0
- fast/lib/libdcmimage.17.dylib +0 -0
- fast/lib/libdcmimgle.17.dylib +0 -0
- fast/lib/libdcmjpeg.17.dylib +0 -0
- fast/lib/libijg12.17.dylib +0 -0
- fast/lib/libijg12.dylib +0 -0
- fast/lib/libijg16.17.dylib +0 -0
- fast/lib/libijg16.dylib +0 -0
- fast/lib/libijg8.17.dylib +0 -0
- fast/lib/libijg8.dylib +0 -0
- fast/lib/libjxl.0.11.dylib +0 -0
- fast/lib/libjxl_cms.0.11.dylib +0 -0
- fast/lib/libjxl_threads.0.11.dylib +0 -0
- fast/lib/liboflog.17.dylib +0 -0
- fast/lib/libofstd.17.dylib +0 -0
- fast/lib/libonnxruntime.1.14.0.dylib +0 -0
- fast/lib/libonnxruntime.dylib +0 -0
- fast/lib/libopenslide.1.dylib +0 -0
- fast/lib/libopenvino.2230.dylib +0 -0
- fast/lib/libopenvino_auto_batch_plugin.so +0 -0
- fast/lib/libopenvino_auto_plugin.so +0 -0
- fast/lib/libopenvino_gapi_preproc.so +0 -0
- fast/lib/libopenvino_hetero_plugin.so +0 -0
- fast/lib/libopenvino_intel_cpu_plugin.so +0 -0
- fast/lib/libopenvino_ir_frontend.2230.dylib +0 -0
- fast/lib/libopenvino_onnx_frontend.2230.dylib +0 -0
- fast/lib/libopenvino_paddle_frontend.2230.dylib +0 -0
- fast/lib/libopenvino_tensorflow_frontend.2230.dylib +0 -0
- fast/lib/libtbb.dylib +0 -0
- fast/lib/libz.1.dylib +0 -0
- fast/lib/plugins.xml +16 -0
- fast/licenses/OpenIGTLink/LICENSE.txt +30 -0
- fast/licenses/OpenJPEG/LICENSE +39 -0
- fast/licenses/OpenSlide/COPYING.LESSER +504 -0
- fast/licenses/PCRE2/LICENCE.md +103 -0
- fast/licenses/cairo/COPYING +33 -0
- fast/licenses/cairo/COPYING-LGPL-2.1 +510 -0
- fast/licenses/cairo/COPYING-MPL-1.1 +470 -0
- fast/licenses/clarius/LICENSE +29 -0
- fast/licenses/dcmtk/COPYRIGHT +1034 -0
- fast/licenses/eigen/COPYING.APACHE +203 -0
- fast/licenses/eigen/COPYING.BSD +26 -0
- fast/licenses/eigen/COPYING.GPL +674 -0
- fast/licenses/eigen/COPYING.LGPL +502 -0
- fast/licenses/eigen/COPYING.MINPACK +51 -0
- fast/licenses/eigen/COPYING.MPL2 +373 -0
- fast/licenses/eigen/COPYING.README +18 -0
- fast/licenses/fast/LICENSE +25 -0
- fast/licenses/gdk-pixbuf/COPYING +502 -0
- fast/licenses/glib/COPYING +175 -0
- fast/licenses/hdf5/COPYING +106 -0
- fast/licenses/jkqtplotter/LICENSE +505 -0
- fast/licenses/jpegxl/LICENSE.brotli +19 -0
- fast/licenses/jpegxl/LICENSE.highway +201 -0
- fast/licenses/jpegxl/LICENSE.jpeg-xl +27 -0
- fast/licenses/jpegxl/LICENSE.skcms +29 -0
- fast/licenses/jpegxl/PATENTS +22 -0
- fast/licenses/libdicom/LICENSE +21 -0
- fast/licenses/libjpeg-turbo/LICENSE.md +135 -0
- fast/licenses/libjpeg-turbo/README.ijg +260 -0
- fast/licenses/libpng/LICENSE +134 -0
- fast/licenses/libtiff/LICENSE.md +23 -0
- fast/licenses/onnxruntime/LICENSE +21 -0
- fast/licenses/onnxruntime/Privacy.md +21 -0
- fast/licenses/onnxruntime/ThirdPartyNotices.txt +5786 -0
- fast/licenses/opencl/LICENSE +201 -0
- fast/licenses/openvino/Apache_license.txt +201 -0
- fast/licenses/openvino/EULA.htm +43 -0
- fast/licenses/openvino/EULA.rtf +61 -0
- fast/licenses/openvino/EULA.txt +163 -0
- fast/licenses/openvino/GNA SOFTWARE LICENSE AGREEMENT.txt +1 -0
- fast/licenses/openvino/Intel_Software_Development_Products.rtf +1217 -0
- fast/licenses/openvino/Intel_Software_Development_Products.txt +707 -0
- fast/licenses/openvino/LICENSE +201 -0
- fast/licenses/openvino/OpenVINOsupport.txt +12 -0
- fast/licenses/openvino/onednn_third-party-programs.txt +557 -0
- fast/licenses/openvino/readme.txt +60 -0
- fast/licenses/openvino/redist.txt +42 -0
- fast/licenses/openvino/runtime-third-party-programs.txt +1400 -0
- fast/licenses/openvino/tbb_third-party-programs.txt +230 -0
- fast/licenses/pixman/COPYING +42 -0
- fast/licenses/proxy-libintl/COPYING +482 -0
- fast/licenses/qt5/LICENSE.FDL +450 -0
- fast/licenses/qt5/LICENSE.GPL3-EXCEPT +704 -0
- fast/licenses/qt5/LICENSE.GPLv2 +292 -0
- fast/licenses/qt5/LICENSE.GPLv3 +686 -0
- fast/licenses/qt5/LICENSE.LGPLv21 +514 -0
- fast/licenses/qt5/LICENSE.LGPLv3 +175 -0
- fast/licenses/qt5/LICENSE.QT-LICENSE-AGREEMENT +1331 -0
- fast/licenses/semaphore/Semaphore_LICENSE.txt +17 -0
- fast/licenses/tensorflow/LICENSE +203 -0
- fast/licenses/tensorflow/THIRD_PARTY_TF_C_LICENSES +8963 -0
- fast/licenses/uthash/LICENSE +21 -0
- fast/licenses/zip/UNLICENSE +26 -0
- fast/licenses/zlib/README +115 -0
- fast/licenses/zlib-ng/LICENSE.md +19 -0
- fast/pipelines/uff_viewer/colormap_and_reject.fpl +26 -0
- fast/pipelines/uff_viewer/default.fpl +9 -0
- fast/pipelines/uff_viewer/non_local_means.fpl +34 -0
- fast/plugins/audio/libqtaudio_coreaudio.dylib +0 -0
- fast/plugins/bearer/libqgenericbearer.dylib +0 -0
- fast/plugins/generic/libqtuiotouchplugin.dylib +0 -0
- fast/plugins/iconengines/libqsvgicon.dylib +0 -0
- fast/plugins/imageformats/libqgif.dylib +0 -0
- fast/plugins/imageformats/libqicns.dylib +0 -0
- fast/plugins/imageformats/libqico.dylib +0 -0
- fast/plugins/imageformats/libqjpeg.dylib +0 -0
- fast/plugins/imageformats/libqmacheif.dylib +0 -0
- fast/plugins/imageformats/libqmacjp2.dylib +0 -0
- fast/plugins/imageformats/libqsvg.dylib +0 -0
- fast/plugins/imageformats/libqtga.dylib +0 -0
- fast/plugins/imageformats/libqtiff.dylib +0 -0
- fast/plugins/imageformats/libqwbmp.dylib +0 -0
- fast/plugins/imageformats/libqwebp.dylib +0 -0
- fast/plugins/mediaservice/libqavfcamera.dylib +0 -0
- fast/plugins/mediaservice/libqavfmediaplayer.dylib +0 -0
- fast/plugins/mediaservice/libqtmedia_audioengine.dylib +0 -0
- fast/plugins/platforms/libqcocoa.dylib +0 -0
- fast/plugins/platforms/libqminimal.dylib +0 -0
- fast/plugins/platforms/libqoffscreen.dylib +0 -0
- fast/plugins/platformthemes/libqxdgdesktopportal.dylib +0 -0
- fast/plugins/playlistformats/libqtmultimedia_m3u.dylib +0 -0
- fast/plugins/printsupport/libcocoaprintersupport.dylib +0 -0
- fast/plugins/sqldrivers/libqsqlite.dylib +0 -0
- fast/plugins/styles/libqmacstyle.dylib +0 -0
- pyfast-4.12.0.dist-info/METADATA +81 -0
- pyfast-4.12.0.dist-info/RECORD +279 -0
- pyfast-4.12.0.dist-info/WHEEL +5 -0
- pyfast-4.12.0.dist-info/entry_points.txt +5 -0
- pyfast-4.12.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
#define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
|
|
4
|
+
|
|
5
|
+
__kernel void initialize(
|
|
6
|
+
__read_only image3d_t input,
|
|
7
|
+
#ifdef fast_3d_image_writes
|
|
8
|
+
__write_only image3d_t distance
|
|
9
|
+
#else
|
|
10
|
+
__global short* distance
|
|
11
|
+
#endif
|
|
12
|
+
) {
|
|
13
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
14
|
+
|
|
15
|
+
uint value = read_imageui(input, sampler, pos).x;
|
|
16
|
+
if(value == 0) {
|
|
17
|
+
// Outside
|
|
18
|
+
#ifdef fast_3d_image_writes
|
|
19
|
+
write_imagei(distance, pos, 0);
|
|
20
|
+
#else
|
|
21
|
+
distance[LPOS(pos)] = 0;
|
|
22
|
+
#endif
|
|
23
|
+
} else {
|
|
24
|
+
// Inside
|
|
25
|
+
bool atBorder = false;
|
|
26
|
+
for(int a = -1; a <= 1; ++a) {
|
|
27
|
+
for(int b = -1; b <= 1; ++b) {
|
|
28
|
+
for(int c = -1; c <= 1; ++c) {
|
|
29
|
+
int4 nPos = (int4)(a,b,c,0) + pos;
|
|
30
|
+
uint value2 = read_imageui(input, sampler, nPos).x;
|
|
31
|
+
if(value2 == 0) {
|
|
32
|
+
atBorder = true;
|
|
33
|
+
}
|
|
34
|
+
}}}
|
|
35
|
+
if(atBorder) {
|
|
36
|
+
#ifdef fast_3d_image_writes
|
|
37
|
+
write_imagei(distance, pos, -1);
|
|
38
|
+
#else
|
|
39
|
+
distance[LPOS(pos)] = -1;
|
|
40
|
+
#endif
|
|
41
|
+
} else {
|
|
42
|
+
#ifdef fast_3d_image_writes
|
|
43
|
+
write_imagei(distance, pos, -1);
|
|
44
|
+
#else
|
|
45
|
+
distance[LPOS(pos)] = -1;
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
__constant int4 neighbors[] = {
|
|
52
|
+
{1, 0, 0, 0},
|
|
53
|
+
{-1, 0, 0, 0},
|
|
54
|
+
{0, 1, 0, 0},
|
|
55
|
+
{0, -1, 0, 0},
|
|
56
|
+
{0, 0, 1, 0},
|
|
57
|
+
{0, 0, -1, 0}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
__kernel void calculateDistance(
|
|
61
|
+
#ifdef fast_3d_image_writes
|
|
62
|
+
__read_only image3d_t input,
|
|
63
|
+
__write_only image3d_t output,
|
|
64
|
+
#else
|
|
65
|
+
__global short* input,
|
|
66
|
+
__global short* output,
|
|
67
|
+
#endif
|
|
68
|
+
__global char* changed
|
|
69
|
+
) {
|
|
70
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
71
|
+
#ifdef fast_3d_image_writes
|
|
72
|
+
int value = read_imagei(input, sampler, pos).x;
|
|
73
|
+
#else
|
|
74
|
+
int value = input[LPOS(pos)];
|
|
75
|
+
#endif
|
|
76
|
+
if(value == -1) { // -1 means no distance calculated yet
|
|
77
|
+
int minNeighborDistance = 999999;
|
|
78
|
+
for(int i = 0; i < 6; ++i) {
|
|
79
|
+
int4 nPos = neighbors[i] + pos;
|
|
80
|
+
#ifdef fast_3d_image_writes
|
|
81
|
+
int value2 = read_imagei(input, sampler, nPos).x;
|
|
82
|
+
#else
|
|
83
|
+
int value2 = input[LPOS(nPos)];
|
|
84
|
+
#endif
|
|
85
|
+
if(value2 < minNeighborDistance && value2 >= 0) {
|
|
86
|
+
minNeighborDistance = value2;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if(minNeighborDistance < 999999) {
|
|
91
|
+
// Valid neighbor found
|
|
92
|
+
#ifdef fast_3d_image_writes
|
|
93
|
+
write_imagei(output, pos, minNeighborDistance+1);
|
|
94
|
+
#else
|
|
95
|
+
output[LPOS(pos)] = minNeighborDistance+1;
|
|
96
|
+
#endif
|
|
97
|
+
changed[0] = 1;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
#ifdef fast_3d_image_writes
|
|
101
|
+
write_imagei(output, pos, value);
|
|
102
|
+
#else
|
|
103
|
+
output[LPOS(pos)] = value;
|
|
104
|
+
#endif
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
__kernel void findCandidateCenterpoints(
|
|
109
|
+
__read_only image3d_t segmentation,
|
|
110
|
+
__read_only image3d_t distanceImage,
|
|
111
|
+
#ifdef fast_3d_image_writes
|
|
112
|
+
__write_only image3d_t output
|
|
113
|
+
#else
|
|
114
|
+
__global uchar* output
|
|
115
|
+
#endif
|
|
116
|
+
) {
|
|
117
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
118
|
+
if(read_imageui(segmentation, sampler, pos).x == 1) {
|
|
119
|
+
// Inside object
|
|
120
|
+
short distance = read_imagei(distanceImage, sampler, pos).x;
|
|
121
|
+
|
|
122
|
+
// Check if voxel is candidate centerline
|
|
123
|
+
int N = 4;
|
|
124
|
+
bool invalid = false;
|
|
125
|
+
for(int a = -N; a <= N; ++a) {
|
|
126
|
+
for(int b = -N; b <= N; ++b) {
|
|
127
|
+
for(int c = -N; c <= N; ++c) {
|
|
128
|
+
short distance2 = read_imagei(distanceImage, sampler, pos + (int4)(a,b,c,0)).x;
|
|
129
|
+
if(distance2 > distance) {
|
|
130
|
+
invalid = true;
|
|
131
|
+
}
|
|
132
|
+
}}}
|
|
133
|
+
|
|
134
|
+
#ifdef fast_3d_image_writes
|
|
135
|
+
if(!invalid) {
|
|
136
|
+
write_imageui(output, pos, 1);
|
|
137
|
+
} else {
|
|
138
|
+
write_imageui(output, pos, 0);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
write_imageui(output, pos, 0);
|
|
142
|
+
}
|
|
143
|
+
#else
|
|
144
|
+
if(!invalid) {
|
|
145
|
+
output[LPOS(pos)] = 1;
|
|
146
|
+
} else {
|
|
147
|
+
output[LPOS(pos)] = 0;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
output[LPOS(pos)] = 0;
|
|
151
|
+
}
|
|
152
|
+
#endif
|
|
153
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
__const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
|
|
2
|
+
|
|
3
|
+
__kernel void convert(
|
|
4
|
+
__read_only image2d_t input,
|
|
5
|
+
__write_only image2d_t output
|
|
6
|
+
) {
|
|
7
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
8
|
+
int dataType = get_image_channel_data_type(input);
|
|
9
|
+
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
10
|
+
uint4 value = read_imageui(input, sampler, pos);
|
|
11
|
+
uint average = round(((float)(value.x + value.y + value.z))/3.0f);
|
|
12
|
+
write_imageui(output, pos, average);
|
|
13
|
+
} else if(dataType == CLK_FLOAT) {
|
|
14
|
+
float4 value = read_imagef(input, sampler, pos);
|
|
15
|
+
float average = value.x + value.y + value.z;
|
|
16
|
+
write_imagef(output, pos, average);
|
|
17
|
+
} else {
|
|
18
|
+
int4 value = read_imagei(input, sampler, pos);
|
|
19
|
+
int average = round(((float)(value.x + value.y + value.z))/3.0f);
|
|
20
|
+
write_imagei(output, pos, average);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
__const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
|
|
2
|
+
|
|
3
|
+
__kernel void convert(
|
|
4
|
+
__read_only image2d_t input,
|
|
5
|
+
__write_only image2d_t output
|
|
6
|
+
) {
|
|
7
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
8
|
+
int dataType = get_image_channel_data_type(input);
|
|
9
|
+
if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
10
|
+
uint value = read_imageui(input, sampler, pos).x;
|
|
11
|
+
write_imageui(output, pos, (uint4)(value, value, value, 255));
|
|
12
|
+
} else if(dataType == CLK_FLOAT) {
|
|
13
|
+
float value = read_imagef(input, sampler, pos).x;
|
|
14
|
+
write_imagef(output, pos, (float4)(value, value, value, 1.0f));
|
|
15
|
+
} else {
|
|
16
|
+
int value = read_imagei(input, sampler, pos).x;
|
|
17
|
+
write_imagei(output, pos, (int4)(value, value, value, 1));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
__kernel void gaussianSmoothing(
|
|
4
|
+
__read_only image2d_t input,
|
|
5
|
+
__constant float * mask,
|
|
6
|
+
__write_only image2d_t output,
|
|
7
|
+
__private unsigned char maskSize
|
|
8
|
+
) {
|
|
9
|
+
|
|
10
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
11
|
+
const unsigned char halfSize = (maskSize-1)/2;
|
|
12
|
+
|
|
13
|
+
float sum = 0.0f;
|
|
14
|
+
int dataType = get_image_channel_data_type(input);
|
|
15
|
+
for(int x = -halfSize; x <= halfSize; x++) {
|
|
16
|
+
for(int y = -halfSize; y <= halfSize; y++) {
|
|
17
|
+
const int2 offset = {x,y};
|
|
18
|
+
if(dataType == CLK_FLOAT) {
|
|
19
|
+
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imagef(input, sampler, pos+offset).x;
|
|
20
|
+
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
21
|
+
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imageui(input, sampler, pos+offset).x;
|
|
22
|
+
} else {
|
|
23
|
+
sum += mask[x+halfSize+(y+halfSize)*maskSize]*read_imagei(input, sampler, pos+offset).x;
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
|
|
27
|
+
int outputDataType = get_image_channel_data_type(output);
|
|
28
|
+
if(outputDataType == CLK_FLOAT) {
|
|
29
|
+
write_imagef(output, pos, sum);
|
|
30
|
+
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16 || outputDataType == CLK_UNSIGNED_INT32) {
|
|
31
|
+
write_imageui(output, pos, round(sum));
|
|
32
|
+
} else {
|
|
33
|
+
write_imagei(output, pos, round(sum));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
#ifdef fast_3d_image_writes
|
|
4
|
+
__kernel void gaussianSmoothing(
|
|
5
|
+
__read_only image3d_t input,
|
|
6
|
+
__constant float * mask,
|
|
7
|
+
__write_only image3d_t output,
|
|
8
|
+
__private unsigned char maskSize,
|
|
9
|
+
__private unsigned char direction
|
|
10
|
+
) {
|
|
11
|
+
|
|
12
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
13
|
+
const unsigned char halfSize = (maskSize-1)/2;
|
|
14
|
+
|
|
15
|
+
float sum = 0.0f;
|
|
16
|
+
int dataType = get_image_channel_data_type(input);
|
|
17
|
+
for(int i = -halfSize; i <= halfSize; ++i) {
|
|
18
|
+
int4 offset = {0,0,0,0};
|
|
19
|
+
if(direction == 0) {
|
|
20
|
+
offset.x = i;
|
|
21
|
+
} else if(direction == 1) {
|
|
22
|
+
offset.y = i;
|
|
23
|
+
} else {
|
|
24
|
+
offset.z = i;
|
|
25
|
+
}
|
|
26
|
+
const uchar maskOffset = halfSize + i;
|
|
27
|
+
if(dataType == CLK_FLOAT) {
|
|
28
|
+
sum += mask[maskOffset]*read_imagef(input, sampler, pos+offset).x;
|
|
29
|
+
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
30
|
+
sum += mask[maskOffset]*read_imageui(input, sampler, pos+offset).x;
|
|
31
|
+
} else {
|
|
32
|
+
sum += mask[maskOffset]*read_imagei(input, sampler, pos+offset).x;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
int outputDataType = get_image_channel_data_type(output);
|
|
37
|
+
if(outputDataType == CLK_FLOAT) {
|
|
38
|
+
write_imagef(output, pos, sum);
|
|
39
|
+
} else if(outputDataType == CLK_UNSIGNED_INT8 || outputDataType == CLK_UNSIGNED_INT16 || outputDataType == CLK_UNSIGNED_INT32) {
|
|
40
|
+
write_imageui(output, pos, round(sum));
|
|
41
|
+
} else {
|
|
42
|
+
write_imagei(output, pos, round(sum));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#else
|
|
47
|
+
__kernel void gaussianSmoothing(
|
|
48
|
+
__read_only image3d_t input,
|
|
49
|
+
__constant float * mask,
|
|
50
|
+
__global TYPE* output,
|
|
51
|
+
__private unsigned char maskSize
|
|
52
|
+
) {
|
|
53
|
+
|
|
54
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
55
|
+
const unsigned char halfSize = (maskSize-1)/2;
|
|
56
|
+
|
|
57
|
+
float sum = 0.0f;
|
|
58
|
+
int dataType = get_image_channel_data_type(input);
|
|
59
|
+
for(int x = -halfSize; x <= halfSize; x++) {
|
|
60
|
+
for(int y = -halfSize; y <= halfSize; y++) {
|
|
61
|
+
for(int z = -halfSize; z <= halfSize; z++) {
|
|
62
|
+
const int4 offset = {x,y,z,0};
|
|
63
|
+
const uint maskOffset = x+halfSize+(y+halfSize)*maskSize+(z+halfSize)*maskSize*maskSize;
|
|
64
|
+
if(dataType == CLK_FLOAT) {
|
|
65
|
+
sum += mask[maskOffset]*read_imagef(input, sampler, pos+offset).x;
|
|
66
|
+
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
67
|
+
sum += mask[maskOffset]*read_imageui(input, sampler, pos+offset).x;
|
|
68
|
+
} else {
|
|
69
|
+
sum += mask[maskOffset]*read_imagei(input, sampler, pos+offset).x;
|
|
70
|
+
}
|
|
71
|
+
}}}
|
|
72
|
+
|
|
73
|
+
output[pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)] = sum;
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
__kernel void GVF2DCopy(__read_only image2d_t input, __write_only image2d_t output) {
|
|
4
|
+
int2 pos = {get_global_id(0), get_global_id(1)};
|
|
5
|
+
write_imagef(output, pos, read_imagef(input, sampler, pos));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
__kernel void GVF2DIteration(__read_only image2d_t init_vector_field, __read_only image2d_t read_vector_field, __write_only image2d_t write_vector_field, __private float mu) {
|
|
9
|
+
|
|
10
|
+
int2 writePos = {get_global_id(0), get_global_id(1)};
|
|
11
|
+
|
|
12
|
+
// Enforce mirror boundary conditions
|
|
13
|
+
int2 size = {get_global_size(0), get_global_size(1)};
|
|
14
|
+
int2 pos = writePos;
|
|
15
|
+
pos = select(pos, (int2)(2,2), pos == (int2)(0,0));
|
|
16
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
17
|
+
|
|
18
|
+
float2 f = read_imagef(read_vector_field, sampler, pos).xy;
|
|
19
|
+
|
|
20
|
+
const float2 init_vector = read_imagef(init_vector_field, sampler, pos).xy;
|
|
21
|
+
|
|
22
|
+
const float2 fx1 = read_imagef(read_vector_field, sampler, pos + (int2)(1,0)).xy;
|
|
23
|
+
const float2 fy1 = read_imagef(read_vector_field, sampler, pos + (int2)(0,1)).xy;
|
|
24
|
+
const float2 fx_1 = read_imagef(read_vector_field, sampler, pos - (int2)(1,0)).xy;
|
|
25
|
+
const float2 fy_1 = read_imagef(read_vector_field, sampler, pos - (int2)(0,1)).xy;
|
|
26
|
+
|
|
27
|
+
// Update the vector field: Calculate Laplacian using a 3D central difference scheme
|
|
28
|
+
float2 laplacian = -4*f + fx1 + fx_1 + fy1 + fy_1;
|
|
29
|
+
|
|
30
|
+
f += mu * laplacian - (f - init_vector)*(init_vector.x*init_vector.x + init_vector.y*init_vector.y);
|
|
31
|
+
|
|
32
|
+
write_imagef(write_vector_field, writePos, (float4)(f.x,f.y,0,0));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// If device supports writing to 3D textures
|
|
37
|
+
#ifdef fast_3d_image_writes
|
|
38
|
+
|
|
39
|
+
__kernel void GVF3DCopy(__read_only image3d_t input, __write_only image3d_t output) {
|
|
40
|
+
int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
41
|
+
write_imagef(output, pos, read_imagef(input, sampler, pos));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
__kernel void GVF3DIteration(
|
|
45
|
+
__read_only image3d_t init_vector_field,
|
|
46
|
+
__read_only image3d_t read_vector_field,
|
|
47
|
+
__write_only image3d_t write_vector_field,
|
|
48
|
+
__private float mu
|
|
49
|
+
) {
|
|
50
|
+
|
|
51
|
+
int4 writePos = {
|
|
52
|
+
get_global_id(0),
|
|
53
|
+
get_global_id(1),
|
|
54
|
+
get_global_id(2),
|
|
55
|
+
0
|
|
56
|
+
};
|
|
57
|
+
// Enforce mirror boundary conditions
|
|
58
|
+
int4 size = {get_image_width(init_vector_field), get_image_height(init_vector_field), get_image_depth(init_vector_field), 0};
|
|
59
|
+
int4 pos = writePos;
|
|
60
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
61
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
62
|
+
|
|
63
|
+
// Load data from memory and do calculations
|
|
64
|
+
float3 init_vector = read_imagef(init_vector_field, sampler, pos).xyz;
|
|
65
|
+
|
|
66
|
+
float3 f = read_imagef(read_vector_field, sampler, pos).xyz;
|
|
67
|
+
float3 fx1 = read_imagef(read_vector_field, sampler, pos + (int4)(1,0,0,0)).xyz;
|
|
68
|
+
float3 fx_1 = read_imagef(read_vector_field, sampler, pos - (int4)(1,0,0,0)).xyz;
|
|
69
|
+
float3 fy1 = read_imagef(read_vector_field, sampler, pos + (int4)(0,1,0,0)).xyz;
|
|
70
|
+
float3 fy_1 = read_imagef(read_vector_field, sampler, pos - (int4)(0,1,0,0)).xyz;
|
|
71
|
+
float3 fz1 = read_imagef(read_vector_field, sampler, pos + (int4)(0,0,1,0)).xyz;
|
|
72
|
+
float3 fz_1 = read_imagef(read_vector_field, sampler, pos - (int4)(0,0,1,0)).xyz;
|
|
73
|
+
|
|
74
|
+
// Update the vector field: Calculate Laplacian using a 3D central difference scheme
|
|
75
|
+
float3 laplacian = -6*f.xyz + fx1 + fx_1 + fy1 + fy_1 + fz1 + fz_1;
|
|
76
|
+
|
|
77
|
+
// NOT ANYMORE: The last component of the input vector is stored in f to save memory (f.w)
|
|
78
|
+
f += mu * laplacian - (f - init_vector)*
|
|
79
|
+
(init_vector.x*init_vector.x + init_vector.y*init_vector.y + init_vector.z*init_vector.z);
|
|
80
|
+
|
|
81
|
+
write_imagef(write_vector_field, writePos, f.xyzz);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#else
|
|
85
|
+
|
|
86
|
+
#define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
|
|
87
|
+
#ifdef VECTORS_16BIT
|
|
88
|
+
#define FLOAT_TO_SNORM16_4(vector) convert_short4_sat_rte(vector * 32767.0f)
|
|
89
|
+
#define SNORM16_TO_FLOAT_4(vector) max(-1.0f, convert_float4(vector) / 32767.0f)
|
|
90
|
+
#define FLOAT_TO_SNORM16_3(vector) convert_short3_sat_rte(vector * 32767.0f)
|
|
91
|
+
#define SNORM16_TO_FLOAT_3(vector) max(-1.0f, convert_float3(vector) / 32767.0f)
|
|
92
|
+
#define FLOAT_TO_SNORM16_2(vector) convert_short2_sat_rte(vector * 32767.0f)
|
|
93
|
+
#define SNORM16_TO_FLOAT_2(vector) max(-1.0f, convert_float2(vector) / 32767.0f)
|
|
94
|
+
#define FLOAT_TO_SNORM16(vector) convert_short_sat_rte(vector * 32767.0f)
|
|
95
|
+
#define SNORM16_TO_FLOAT(vector) max(-1.0f, convert_float(vector) / 32767.0f)
|
|
96
|
+
#define VECTOR_FIELD_TYPE short
|
|
97
|
+
#else
|
|
98
|
+
#define FLOAT_TO_SNORM16_4(vector) vector
|
|
99
|
+
#define SNORM16_TO_FLOAT_4(vector) vector
|
|
100
|
+
#define FLOAT_TO_SNORM16_3(vector) vector
|
|
101
|
+
#define SNORM16_TO_FLOAT_3(vector) vector
|
|
102
|
+
#define FLOAT_TO_SNORM16_2(vector) vector
|
|
103
|
+
#define SNORM16_TO_FLOAT_2(vector) vector
|
|
104
|
+
#define FLOAT_TO_SNORM16(vector) vector
|
|
105
|
+
#define SNORM16_TO_FLOAT(vector) vector
|
|
106
|
+
#define VECTOR_FIELD_TYPE float
|
|
107
|
+
#endif
|
|
108
|
+
|
|
109
|
+
__kernel void GVF3DIteration(
|
|
110
|
+
__read_only image3d_t init_vector_field,
|
|
111
|
+
__global VECTOR_FIELD_TYPE const * restrict read_vector_field,
|
|
112
|
+
__global VECTOR_FIELD_TYPE * write_vector_field,
|
|
113
|
+
__private float mu
|
|
114
|
+
) {
|
|
115
|
+
int4 writePos = {
|
|
116
|
+
get_global_id(0),
|
|
117
|
+
get_global_id(1),
|
|
118
|
+
get_global_id(2),
|
|
119
|
+
0
|
|
120
|
+
};
|
|
121
|
+
// Enforce mirror boundary conditions
|
|
122
|
+
int4 size = {get_global_size(0), get_global_size(1), get_global_size(2), 0};
|
|
123
|
+
int4 pos = writePos;
|
|
124
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
125
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
126
|
+
int offset = pos.x + pos.y*size.x + pos.z*size.x*size.y;
|
|
127
|
+
|
|
128
|
+
// Load data from shared memory and do calculations
|
|
129
|
+
float4 init_vector = read_imagef(init_vector_field, sampler, pos);
|
|
130
|
+
|
|
131
|
+
float3 v = SNORM16_TO_FLOAT_3(vload3(offset, read_vector_field));
|
|
132
|
+
float3 fx1 = SNORM16_TO_FLOAT_3(vload3(offset+1, read_vector_field));
|
|
133
|
+
float3 fx_1 = SNORM16_TO_FLOAT_3(vload3(offset-1, read_vector_field));
|
|
134
|
+
float3 fy1 = SNORM16_TO_FLOAT_3(vload3(offset+size.x, read_vector_field));
|
|
135
|
+
float3 fy_1 = SNORM16_TO_FLOAT_3(vload3(offset-size.x, read_vector_field));
|
|
136
|
+
float3 fz1 = SNORM16_TO_FLOAT_3(vload3(offset+size.x*size.y, read_vector_field));
|
|
137
|
+
float3 fz_1 = SNORM16_TO_FLOAT_3(vload3(offset-size.x*size.y, read_vector_field));
|
|
138
|
+
|
|
139
|
+
// Update the vector field: Calculate Laplacian using a 3D central difference scheme
|
|
140
|
+
float3 v2;
|
|
141
|
+
v2.x = -6*v.x;
|
|
142
|
+
v2.y = -6*v.y;
|
|
143
|
+
v2.z = -6*v.z;
|
|
144
|
+
float3 laplacian = v2 + fx1 + fx_1 + fy1 + fy_1 + fz1 + fz_1;
|
|
145
|
+
|
|
146
|
+
v += mu*laplacian - (v - init_vector.xyz)*(init_vector.x*init_vector.x + init_vector.y*init_vector.y + init_vector.z*init_vector.z);
|
|
147
|
+
|
|
148
|
+
vstore3(FLOAT_TO_SNORM16_3(v), writePos.x + writePos.y*size.x + writePos.z*size.x*size.y, write_vector_field);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
__kernel void GVF3DInit(
|
|
153
|
+
__read_only image3d_t vectorFieldImage,
|
|
154
|
+
__global VECTOR_FIELD_TYPE * vectorField
|
|
155
|
+
) {
|
|
156
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
157
|
+
vstore3(FLOAT_TO_SNORM16_3(read_imagef(vectorFieldImage, sampler, pos).xyz), LPOS(pos), vectorField);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
__kernel void GVF3DFinish(
|
|
161
|
+
__global VECTOR_FIELD_TYPE * vectorField,
|
|
162
|
+
//__global VECTOR_FIELD_TYPE * vectorField2
|
|
163
|
+
__global float * vectorField2
|
|
164
|
+
) {
|
|
165
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
166
|
+
float4 v;
|
|
167
|
+
v.xyz = SNORM16_TO_FLOAT_3(vload3(LPOS(pos), vectorField));
|
|
168
|
+
v.w = 0;
|
|
169
|
+
v.w = length(v) > 0.0f ? length(v) : 1.0f;
|
|
170
|
+
//vstore4(FLOAT_TO_SNORM16_4(v), LPOS(pos), vectorField2);
|
|
171
|
+
vstore4(v, LPOS(pos), vectorField2);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#endif
|