pyfast 4.12.0__cp36-abi3-macosx_11_0_arm64.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 +19833 -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/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.22.0.dylib +0 -0
- fast/lib/libonnxruntime.dylib +0 -0
- fast/lib/libopenslide.1.dylib +0 -0
- fast/lib/libz.1.dylib +0 -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/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 +6156 -0
- fast/licenses/opencl/LICENSE +201 -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 +1315 -0
- fast/licenses/semaphore/Semaphore_LICENSE.txt +17 -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 +248 -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,407 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
__constant sampler_t hpSampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
|
|
3
|
+
|
|
4
|
+
#define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
|
|
5
|
+
|
|
6
|
+
#ifdef VECTORS_16BIT
|
|
7
|
+
#define FLOAT_TO_SNORM16_4(vector) convert_short4_sat_rte(vector * 32767.0f)
|
|
8
|
+
#define FLOAT_TO_SNORM16_3(vector) convert_short3_sat_rte(vector * 32767.0f)
|
|
9
|
+
#define FLOAT_TO_SNORM16_2(vector) convert_short2_sat_rte(vector * 32767.0f)
|
|
10
|
+
#define FLOAT_TO_SNORM16(vector) convert_short_sat_rte(vector * 32767.0f)
|
|
11
|
+
#define VECTOR_FIELD_TYPE short
|
|
12
|
+
#else
|
|
13
|
+
#define FLOAT_TO_SNORM16_4(vector) vector
|
|
14
|
+
#define FLOAT_TO_SNORM16_3(vector) vector
|
|
15
|
+
#define FLOAT_TO_SNORM16_2(vector) vector
|
|
16
|
+
#define FLOAT_TO_SNORM16(vector) vector
|
|
17
|
+
#define VECTOR_FIELD_TYPE float
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
__kernel void GVFgaussSeidel(
|
|
21
|
+
__read_only image3d_t r,
|
|
22
|
+
__read_only image3d_t sqrMag,
|
|
23
|
+
__private float mu,
|
|
24
|
+
__private float spacing,
|
|
25
|
+
__read_only image3d_t v_read,
|
|
26
|
+
#ifdef fast_3d_image_writes
|
|
27
|
+
__write_only image3d_t v_write
|
|
28
|
+
#else
|
|
29
|
+
__global VECTOR_FIELD_TYPE * v_write
|
|
30
|
+
#endif
|
|
31
|
+
) {
|
|
32
|
+
int4 writePos = {
|
|
33
|
+
get_global_id(0),
|
|
34
|
+
get_global_id(1),
|
|
35
|
+
get_global_id(2),
|
|
36
|
+
0
|
|
37
|
+
};
|
|
38
|
+
// Enforce mirror boundary conditions
|
|
39
|
+
int4 size = {get_global_size(0), get_global_size(1), get_global_size(2), 0};
|
|
40
|
+
int4 pos = writePos;
|
|
41
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
42
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
43
|
+
|
|
44
|
+
// Calculate manhatten address
|
|
45
|
+
int i = pos.x+pos.y+pos.z;
|
|
46
|
+
|
|
47
|
+
// Compute red and put into v_write
|
|
48
|
+
if(i % 2 == 0) {
|
|
49
|
+
float value = native_divide(2.0f*mu*(
|
|
50
|
+
read_imagef(v_read, sampler, pos + (int4)(1,0,0,0)).x+
|
|
51
|
+
read_imagef(v_read, sampler, pos - (int4)(1,0,0,0)).x+
|
|
52
|
+
read_imagef(v_read, sampler, pos + (int4)(0,1,0,0)).x+
|
|
53
|
+
read_imagef(v_read, sampler, pos - (int4)(0,1,0,0)).x+
|
|
54
|
+
read_imagef(v_read, sampler, pos + (int4)(0,0,1,0)).x+
|
|
55
|
+
read_imagef(v_read, sampler, pos - (int4)(0,0,1,0)).x
|
|
56
|
+
) - 2.0f*spacing*spacing*read_imagef(r, sampler, pos).x,
|
|
57
|
+
12.0f*mu+spacing*spacing*read_imagef(sqrMag, sampler, pos).x);
|
|
58
|
+
#ifdef fast_3d_image_writes
|
|
59
|
+
write_imagef(v_write, writePos, value);
|
|
60
|
+
#else
|
|
61
|
+
v_write[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
62
|
+
#endif
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
__kernel void GVFgaussSeidel2(
|
|
67
|
+
__read_only image3d_t r,
|
|
68
|
+
__read_only image3d_t sqrMag,
|
|
69
|
+
__private float mu,
|
|
70
|
+
__private float spacing,
|
|
71
|
+
__read_only image3d_t v_read,
|
|
72
|
+
#ifdef fast_3d_image_writes
|
|
73
|
+
__write_only image3d_t v_write
|
|
74
|
+
#else
|
|
75
|
+
__global VECTOR_FIELD_TYPE * v_write
|
|
76
|
+
#endif
|
|
77
|
+
) {
|
|
78
|
+
int4 writePos = {
|
|
79
|
+
get_global_id(0),
|
|
80
|
+
get_global_id(1),
|
|
81
|
+
get_global_id(2),
|
|
82
|
+
0
|
|
83
|
+
};
|
|
84
|
+
// Enforce mirror boundary conditions
|
|
85
|
+
int4 size = {get_global_size(0), get_global_size(1), get_global_size(2), 0};
|
|
86
|
+
int4 pos = writePos;
|
|
87
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
88
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
89
|
+
|
|
90
|
+
// Calculate manhatten address
|
|
91
|
+
int i = pos.x+pos.y+pos.z;
|
|
92
|
+
float value;
|
|
93
|
+
if(i % 2 == 0) {
|
|
94
|
+
// Copy red
|
|
95
|
+
value = read_imagef(v_read, sampler, pos).x;
|
|
96
|
+
} else {
|
|
97
|
+
// Compute black
|
|
98
|
+
value = native_divide(2.0f*mu*(
|
|
99
|
+
read_imagef(v_read, sampler, pos + (int4)(1,0,0,0)).x+
|
|
100
|
+
read_imagef(v_read, sampler, pos - (int4)(1,0,0,0)).x+
|
|
101
|
+
read_imagef(v_read, sampler, pos + (int4)(0,1,0,0)).x+
|
|
102
|
+
read_imagef(v_read, sampler, pos - (int4)(0,1,0,0)).x+
|
|
103
|
+
read_imagef(v_read, sampler, pos + (int4)(0,0,1,0)).x+
|
|
104
|
+
read_imagef(v_read, sampler, pos - (int4)(0,0,1,0)).x
|
|
105
|
+
) - 2.0f*spacing*spacing*read_imagef(r, sampler, pos).x,
|
|
106
|
+
12.0f*mu+spacing*spacing*read_imagef(sqrMag, sampler, pos).x);
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
#ifdef fast_3d_image_writes
|
|
111
|
+
write_imagef(v_write, writePos, value);
|
|
112
|
+
#else
|
|
113
|
+
v_write[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
114
|
+
#endif
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
__kernel void addTwoImages(
|
|
119
|
+
__read_only image3d_t i1,
|
|
120
|
+
__read_only image3d_t i2,
|
|
121
|
+
#ifdef fast_3d_image_writes
|
|
122
|
+
__write_only image3d_t i3
|
|
123
|
+
#else
|
|
124
|
+
__global VECTOR_FIELD_TYPE * i3
|
|
125
|
+
#endif
|
|
126
|
+
) {
|
|
127
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
128
|
+
float v = read_imagef(i1,sampler,pos).x+read_imagef(i2,sampler,pos).x;
|
|
129
|
+
#ifdef fast_3d_image_writes
|
|
130
|
+
write_imagef(i3,pos,v);
|
|
131
|
+
#else
|
|
132
|
+
i3[LPOS(pos)] = FLOAT_TO_SNORM16(v);
|
|
133
|
+
#endif
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
__kernel void createSqrMag(
|
|
138
|
+
__read_only image3d_t vectorField,
|
|
139
|
+
#ifdef fast_3d_image_writes
|
|
140
|
+
__write_only image3d_t sqrMag
|
|
141
|
+
#else
|
|
142
|
+
__global VECTOR_FIELD_TYPE * sqrMag
|
|
143
|
+
#endif
|
|
144
|
+
) {
|
|
145
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
146
|
+
|
|
147
|
+
const float4 v = read_imagef(vectorField, sampler, pos);
|
|
148
|
+
|
|
149
|
+
float mag = v.x*v.x+v.y*v.y+v.z*v.z;
|
|
150
|
+
#ifdef fast_3d_image_writes
|
|
151
|
+
write_imagef(sqrMag, pos, mag);
|
|
152
|
+
#else
|
|
153
|
+
sqrMag[LPOS(pos)] = FLOAT_TO_SNORM16(mag);
|
|
154
|
+
#endif
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
__kernel void MGGVFInit(
|
|
158
|
+
__read_only image3d_t vectorField,
|
|
159
|
+
#ifdef fast_3d_image_writes
|
|
160
|
+
__write_only image3d_t f,
|
|
161
|
+
__write_only image3d_t r,
|
|
162
|
+
#else
|
|
163
|
+
__global VECTOR_FIELD_TYPE * f,
|
|
164
|
+
__global VECTOR_FIELD_TYPE * r,
|
|
165
|
+
#endif
|
|
166
|
+
__private int component
|
|
167
|
+
) {
|
|
168
|
+
|
|
169
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
170
|
+
|
|
171
|
+
const float4 v = read_imagef(vectorField, sampler, pos);
|
|
172
|
+
const float sqrMag = v.x*v.x+v.y*v.y+v.z*v.z;
|
|
173
|
+
float f_value, r_value;
|
|
174
|
+
if(component == 1) {
|
|
175
|
+
f_value = v.x;
|
|
176
|
+
r_value = -v.x*sqrMag;
|
|
177
|
+
} else if(component == 2) {
|
|
178
|
+
f_value = v.y;
|
|
179
|
+
r_value = -v.y*sqrMag;
|
|
180
|
+
} else {
|
|
181
|
+
f_value = v.z;
|
|
182
|
+
r_value = -v.z*sqrMag;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
#ifdef fast_3d_image_writes
|
|
186
|
+
write_imagef(f, pos, f_value);
|
|
187
|
+
write_imagef(r, pos, r_value);
|
|
188
|
+
#else
|
|
189
|
+
f[LPOS(pos)] = FLOAT_TO_SNORM16(f_value);
|
|
190
|
+
r[LPOS(pos)] = FLOAT_TO_SNORM16(r_value);
|
|
191
|
+
#endif
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
__kernel void MGGVFFinish(
|
|
195
|
+
__read_only image3d_t fx,
|
|
196
|
+
__read_only image3d_t fy,
|
|
197
|
+
__read_only image3d_t fz,
|
|
198
|
+
#ifdef fast_3d_image_writes
|
|
199
|
+
__write_only image3d_t vectorField
|
|
200
|
+
#else
|
|
201
|
+
//__global VECTOR_FIELD_TYPE * vectorField
|
|
202
|
+
__global float* vectorField
|
|
203
|
+
#endif
|
|
204
|
+
) {
|
|
205
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
206
|
+
|
|
207
|
+
float4 value;
|
|
208
|
+
value.x = read_imagef(fx,sampler,pos).x;
|
|
209
|
+
value.y = read_imagef(fy,sampler,pos).x;
|
|
210
|
+
value.z = read_imagef(fz,sampler,pos).x;
|
|
211
|
+
value.w = length(value.xyz);
|
|
212
|
+
#ifdef fast_3d_image_writes
|
|
213
|
+
write_imagef(vectorField,pos,value);
|
|
214
|
+
#else
|
|
215
|
+
//vstore4(FLOAT_TO_SNORM16_4(value), LPOS(pos), vectorField);
|
|
216
|
+
vstore4(value, LPOS(pos), vectorField);
|
|
217
|
+
#endif
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
__kernel void restrictVolume(
|
|
221
|
+
__read_only image3d_t v_read,
|
|
222
|
+
#ifdef fast_3d_image_writes
|
|
223
|
+
__write_only image3d_t v_write
|
|
224
|
+
#else
|
|
225
|
+
__global VECTOR_FIELD_TYPE * v_write
|
|
226
|
+
#endif
|
|
227
|
+
) {
|
|
228
|
+
int4 writePos = {
|
|
229
|
+
get_global_id(0),
|
|
230
|
+
get_global_id(1),
|
|
231
|
+
get_global_id(2),
|
|
232
|
+
0
|
|
233
|
+
};
|
|
234
|
+
// Enforce mirror boundary conditions
|
|
235
|
+
int4 size = {get_global_size(0)*2, get_global_size(1)*2, get_global_size(2)*2, 0};
|
|
236
|
+
int4 pos = writePos*2;
|
|
237
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
238
|
+
|
|
239
|
+
const int4 readPos = pos;
|
|
240
|
+
const float value = 0.125*(
|
|
241
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(0,0,0,0)).x +
|
|
242
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(1,0,0,0)).x +
|
|
243
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(0,1,0,0)).x +
|
|
244
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(0,0,1,0)).x +
|
|
245
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(1,1,0,0)).x +
|
|
246
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(0,1,1,0)).x +
|
|
247
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(1,1,1,0)).x +
|
|
248
|
+
read_imagef(v_read, hpSampler, readPos+(int4)(1,0,1,0)).x
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
#ifdef fast_3d_image_writes
|
|
252
|
+
write_imagef(v_write, writePos, value);
|
|
253
|
+
#else
|
|
254
|
+
v_write[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
255
|
+
#endif
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
__kernel void prolongate(
|
|
259
|
+
__read_only image3d_t v_l_read,
|
|
260
|
+
__read_only image3d_t v_l_p1,
|
|
261
|
+
#ifdef fast_3d_image_writes
|
|
262
|
+
__write_only image3d_t v_l_write
|
|
263
|
+
#else
|
|
264
|
+
__global VECTOR_FIELD_TYPE * v_l_write
|
|
265
|
+
#endif
|
|
266
|
+
) {
|
|
267
|
+
const int4 writePos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
268
|
+
const int4 readPos = convert_int4(floor(convert_float4(writePos)/2.0f));
|
|
269
|
+
float value = read_imagef(v_l_read, hpSampler, writePos).x + read_imagef(v_l_p1, hpSampler, readPos).x;
|
|
270
|
+
#ifdef fast_3d_image_writes
|
|
271
|
+
write_imagef(v_l_write, writePos, value);
|
|
272
|
+
#else
|
|
273
|
+
v_l_write[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
274
|
+
#endif
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
__kernel void prolongate2(
|
|
278
|
+
__read_only image3d_t v_l_p1,
|
|
279
|
+
#ifdef fast_3d_image_writes
|
|
280
|
+
__write_only image3d_t v_l_write
|
|
281
|
+
#else
|
|
282
|
+
__global VECTOR_FIELD_TYPE * v_l_write
|
|
283
|
+
#endif
|
|
284
|
+
) {
|
|
285
|
+
const int4 writePos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
286
|
+
const int4 readPos = convert_int4(floor(convert_float4(writePos)/2.0f));
|
|
287
|
+
#ifdef fast_3d_image_writes
|
|
288
|
+
write_imagef(v_l_write, writePos, read_imagef(v_l_p1, hpSampler, readPos).x);
|
|
289
|
+
#else
|
|
290
|
+
v_l_write[LPOS(writePos)] = FLOAT_TO_SNORM16(read_imagef(v_l_p1, hpSampler, readPos).x);
|
|
291
|
+
#endif
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
__kernel void residual(
|
|
296
|
+
__read_only image3d_t r,
|
|
297
|
+
__read_only image3d_t v,
|
|
298
|
+
__read_only image3d_t sqrMag,
|
|
299
|
+
__private float mu,
|
|
300
|
+
__private float spacing,
|
|
301
|
+
#ifdef fast_3d_image_writes
|
|
302
|
+
__write_only image3d_t newResidual
|
|
303
|
+
#else
|
|
304
|
+
__global VECTOR_FIELD_TYPE * newResidual
|
|
305
|
+
#endif
|
|
306
|
+
) {
|
|
307
|
+
int4 writePos = {
|
|
308
|
+
get_global_id(0),
|
|
309
|
+
get_global_id(1),
|
|
310
|
+
get_global_id(2),
|
|
311
|
+
0
|
|
312
|
+
};
|
|
313
|
+
// Enforce mirror boundary conditions
|
|
314
|
+
int4 size = {get_global_size(0), get_global_size(1), get_global_size(2), 0};
|
|
315
|
+
int4 pos = writePos;
|
|
316
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
317
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
318
|
+
|
|
319
|
+
const float value = read_imagef(r, hpSampler, pos).x -
|
|
320
|
+
((mu*(
|
|
321
|
+
read_imagef(v, hpSampler, pos+(int4)(1,0,0,0)).x+
|
|
322
|
+
read_imagef(v, hpSampler, pos-(int4)(1,0,0,0)).x+
|
|
323
|
+
read_imagef(v, hpSampler, pos+(int4)(0,1,0,0)).x+
|
|
324
|
+
read_imagef(v, hpSampler, pos-(int4)(0,1,0,0)).x+
|
|
325
|
+
read_imagef(v, hpSampler, pos+(int4)(0,0,1,0)).x+
|
|
326
|
+
read_imagef(v, hpSampler, pos-(int4)(0,0,1,0)).x-
|
|
327
|
+
6*read_imagef(v, hpSampler, pos).x
|
|
328
|
+
) / (spacing*spacing))
|
|
329
|
+
- read_imagef(sqrMag, hpSampler, pos).x*read_imagef(v, hpSampler, pos).x);
|
|
330
|
+
|
|
331
|
+
#ifdef fast_3d_image_writes
|
|
332
|
+
write_imagef(newResidual, writePos, value);
|
|
333
|
+
#else
|
|
334
|
+
newResidual[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
335
|
+
#endif
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
__kernel void fmgResidual(
|
|
339
|
+
__read_only image3d_t vectorField,
|
|
340
|
+
__read_only image3d_t v,
|
|
341
|
+
__private float mu,
|
|
342
|
+
__private float spacing,
|
|
343
|
+
__private int component,
|
|
344
|
+
#ifdef fast_3d_image_writes
|
|
345
|
+
__write_only image3d_t newResidual
|
|
346
|
+
#else
|
|
347
|
+
__global VECTOR_FIELD_TYPE * newResidual
|
|
348
|
+
#endif
|
|
349
|
+
) {
|
|
350
|
+
int4 writePos = {
|
|
351
|
+
get_global_id(0),
|
|
352
|
+
get_global_id(1),
|
|
353
|
+
get_global_id(2),
|
|
354
|
+
0
|
|
355
|
+
};
|
|
356
|
+
// Enforce mirror boundary conditions
|
|
357
|
+
int4 size = {get_global_size(0), get_global_size(1), get_global_size(2), 0};
|
|
358
|
+
int4 pos = writePos;
|
|
359
|
+
pos = select(pos, (int4)(2,2,2,0), pos == (int4)(0,0,0,0));
|
|
360
|
+
pos = select(pos, size-3, pos >= size-1);
|
|
361
|
+
|
|
362
|
+
float4 vector = read_imagef(vectorField, sampler, pos);
|
|
363
|
+
float v0;
|
|
364
|
+
if(component == 1) {
|
|
365
|
+
v0 = vector.x;
|
|
366
|
+
} else if(component == 2) {
|
|
367
|
+
v0 = vector.y;
|
|
368
|
+
} else {
|
|
369
|
+
v0 = vector.z;
|
|
370
|
+
}
|
|
371
|
+
const float sqrMag = vector.x*vector.x+vector.y*vector.y+vector.z*vector.z;
|
|
372
|
+
|
|
373
|
+
float residue = (mu*(
|
|
374
|
+
read_imagef(v, hpSampler, pos+(int4)(1,0,0,0)).x+
|
|
375
|
+
read_imagef(v, hpSampler, pos-(int4)(1,0,0,0)).x+
|
|
376
|
+
read_imagef(v, hpSampler, pos+(int4)(0,1,0,0)).x+
|
|
377
|
+
read_imagef(v, hpSampler, pos-(int4)(0,1,0,0)).x+
|
|
378
|
+
read_imagef(v, hpSampler, pos+(int4)(0,0,1,0)).x+
|
|
379
|
+
read_imagef(v, hpSampler, pos-(int4)(0,0,1,0)).x-
|
|
380
|
+
6*read_imagef(v, hpSampler, pos).x)
|
|
381
|
+
) / (spacing*spacing);
|
|
382
|
+
|
|
383
|
+
//printf("sqrMag: %f, vector value: %f %f %f\n", sqrMag, vector.x, vector.y, vector.z);
|
|
384
|
+
const float value = -sqrMag*v0-(residue - sqrMag*read_imagef(v, hpSampler, pos).x);
|
|
385
|
+
|
|
386
|
+
#ifdef fast_3d_image_writes
|
|
387
|
+
write_imagef(newResidual, writePos, value);
|
|
388
|
+
#else
|
|
389
|
+
newResidual[LPOS(writePos)] = FLOAT_TO_SNORM16(value);
|
|
390
|
+
#endif
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
#ifdef fast_3d_image_writes
|
|
395
|
+
__kernel void init3DFloat(
|
|
396
|
+
__write_only image3d_t v
|
|
397
|
+
) {
|
|
398
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
399
|
+
write_imagef(v, pos, 0.0f);
|
|
400
|
+
}
|
|
401
|
+
#else
|
|
402
|
+
__kernel void initFloatBuffer(
|
|
403
|
+
__global VECTOR_FIELD_TYPE * buffer
|
|
404
|
+
) {
|
|
405
|
+
buffer[get_global_id(0)] = FLOAT_TO_SNORM16(0.0f);
|
|
406
|
+
}
|
|
407
|
+
#endif
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | 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 convertToHU(
|
|
6
|
+
__read_only image3d_t input,
|
|
7
|
+
#ifdef fast_3d_image_writes
|
|
8
|
+
__write_only image3d_t output
|
|
9
|
+
#else
|
|
10
|
+
__global short* output
|
|
11
|
+
#endif
|
|
12
|
+
) {
|
|
13
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
14
|
+
|
|
15
|
+
int value = read_imageui(input, sampler, pos).x;
|
|
16
|
+
value -= 1024;
|
|
17
|
+
#ifdef fast_3d_image_writes
|
|
18
|
+
write_imagei(output, pos, value);
|
|
19
|
+
#else
|
|
20
|
+
output[LPOS(pos)] = value;
|
|
21
|
+
#endif
|
|
22
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 position) {
|
|
4
|
+
int dataType = get_image_channel_data_type(image);
|
|
5
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
6
|
+
return read_imagef(image, sampler, position);
|
|
7
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
8
|
+
return convert_float4(read_imagei(image, sampler, position));
|
|
9
|
+
} else {
|
|
10
|
+
return convert_float4(read_imageui(image, sampler, position));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float4 value) {
|
|
16
|
+
int dataType = get_image_channel_data_type(image);
|
|
17
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
18
|
+
write_imagef(image, position, value);
|
|
19
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
20
|
+
write_imagei(image, position, convert_int4(round(value)));
|
|
21
|
+
} else {
|
|
22
|
+
write_imageui(image, position, convert_uint4(round(value)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
float4 readImageAsFloat3D(__read_only image3d_t image, sampler_t sampler, int4 position) {
|
|
27
|
+
int dataType = get_image_channel_data_type(image);
|
|
28
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
29
|
+
return read_imagef(image, sampler, position);
|
|
30
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
31
|
+
return convert_float4(read_imagei(image, sampler, position));
|
|
32
|
+
} else {
|
|
33
|
+
return convert_float4(read_imageui(image, sampler, position));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
__kernel void add3D(
|
|
38
|
+
__read_only image3d_t input1,
|
|
39
|
+
__read_only image3d_t input2,
|
|
40
|
+
__global DATA_TYPE* output,
|
|
41
|
+
__private uint outputChannels
|
|
42
|
+
) {
|
|
43
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
44
|
+
|
|
45
|
+
float4 value1 = readImageAsFloat3D(input1, sampler, pos);
|
|
46
|
+
float4 value2 = readImageAsFloat3D(input2, sampler, pos);
|
|
47
|
+
float4 value = value1+value2;
|
|
48
|
+
|
|
49
|
+
output[(pos.x + pos.y*get_image_width(input1) + pos.z*get_image_width(input1)*get_image_height(input1))*outputChannels] = value.x;
|
|
50
|
+
if(outputChannels > 1)
|
|
51
|
+
output[(pos.x + pos.y*get_image_width(input1) + pos.z*get_image_width(input1)*get_image_height(input1))*outputChannels + 1] = value.y;
|
|
52
|
+
if(outputChannels > 2)
|
|
53
|
+
output[(pos.x + pos.y*get_image_width(input1) + pos.z*get_image_width(input1)*get_image_height(input1))*outputChannels + 2] = value.z;
|
|
54
|
+
if(outputChannels > 3)
|
|
55
|
+
output[(pos.x + pos.y*get_image_width(input1) + pos.z*get_image_width(input1)*get_image_height(input1))*outputChannels + 3] = value.w;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
__kernel void add2D(
|
|
59
|
+
__read_only image2d_t input1,
|
|
60
|
+
__read_only image2d_t input2,
|
|
61
|
+
__write_only image2d_t output,
|
|
62
|
+
__private uint input1Channels,
|
|
63
|
+
__private uint input2Channels,
|
|
64
|
+
__private uint outputChannels
|
|
65
|
+
) {
|
|
66
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
67
|
+
|
|
68
|
+
float4 value1 = readImageAsFloat2D(input1, sampler, pos);
|
|
69
|
+
float4 value2 = readImageAsFloat2D(input2, sampler, pos);
|
|
70
|
+
float4 value;
|
|
71
|
+
if(input1Channels == input2Channels) {
|
|
72
|
+
value = value1+value2;
|
|
73
|
+
} else if(input1Channels == 1) {
|
|
74
|
+
value = value1.x+value2;
|
|
75
|
+
} else if(input2Channels == 1) {
|
|
76
|
+
value = value1+value2.x;
|
|
77
|
+
}
|
|
78
|
+
writeImageAsFloat2D(output, pos, value);
|
|
79
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
float4 readImageAsFloat2D(__read_only image2d_t image, sampler_t sampler, int2 position) {
|
|
4
|
+
int dataType = get_image_channel_data_type(image);
|
|
5
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
6
|
+
return read_imagef(image, sampler, position);
|
|
7
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
8
|
+
return convert_float4(read_imagei(image, sampler, position));
|
|
9
|
+
} else {
|
|
10
|
+
return convert_float4(read_imageui(image, sampler, position));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void writeImageAsFloat2D(__write_only image2d_t image, int2 position, float4 value) {
|
|
15
|
+
int dataType = get_image_channel_data_type(image);
|
|
16
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
17
|
+
write_imagef(image, position, value);
|
|
18
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
19
|
+
write_imagei(image, position, convert_int4(round(value)));
|
|
20
|
+
} else {
|
|
21
|
+
write_imageui(image, position, convert_uint4(round(value)));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
__kernel void cast2D(
|
|
26
|
+
__read_only image2d_t input,
|
|
27
|
+
__write_only image2d_t output,
|
|
28
|
+
__private float scaleFactor
|
|
29
|
+
) {
|
|
30
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
31
|
+
const int dataType = get_image_channel_data_type(output);
|
|
32
|
+
|
|
33
|
+
if(dataType == CLK_FLOAT || dataType == CLK_SNORM_INT16 || dataType == CLK_UNORM_INT16) {
|
|
34
|
+
writeImageAsFloat2D(output, pos, readImageAsFloat2D(input, sampler, pos)*scaleFactor);
|
|
35
|
+
} else {
|
|
36
|
+
writeImageAsFloat2D(output, pos, round(readImageAsFloat2D(input, sampler, pos)*scaleFactor));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
__kernel void channelConvert2D(
|
|
6
|
+
__read_only image2d_t input,
|
|
7
|
+
__write_only image2d_t output,
|
|
8
|
+
__private uchar4 removeChannelV,
|
|
9
|
+
__private char reverse,
|
|
10
|
+
__private int nrOfChannels
|
|
11
|
+
) {
|
|
12
|
+
|
|
13
|
+
int offset = 0;
|
|
14
|
+
int sign = 1;
|
|
15
|
+
if(reverse == 1) {
|
|
16
|
+
offset = (nrOfChannels-1) - (removeChannelV.x + removeChannelV.y + removeChannelV.z + removeChannelV.w);
|
|
17
|
+
sign = -1;
|
|
18
|
+
}
|
|
19
|
+
uchar* removeChannel = (uchar*)&removeChannelV;
|
|
20
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
21
|
+
int type = get_image_channel_data_type(input);
|
|
22
|
+
int writePos = 0;
|
|
23
|
+
if(type == CLK_FLOAT) {
|
|
24
|
+
float4 tmp = read_imagef(input, sampler, pos);
|
|
25
|
+
float* pixel = (float*)&tmp;
|
|
26
|
+
float result[4];
|
|
27
|
+
for(int i = 0; i < 4; ++i) {
|
|
28
|
+
if(removeChannel[i] == 0) {
|
|
29
|
+
result[writePos*sign + offset] = pixel[i];
|
|
30
|
+
++writePos;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
write_imagef(output, pos, (float4)(result[0], result[1], result[2], result[3]));
|
|
35
|
+
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16 || type == CLK_UNSIGNED_INT32) {
|
|
36
|
+
uint4 tmp = read_imageui(input, sampler, pos);
|
|
37
|
+
uint* pixel = (uint*)&tmp;
|
|
38
|
+
uint result[4];
|
|
39
|
+
for(int i = 0; i < 4; ++i) {
|
|
40
|
+
if(removeChannel[i] == 0) {
|
|
41
|
+
result[writePos*sign + offset] = pixel[i];
|
|
42
|
+
++writePos;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
write_imageui(output, pos, (uint4)(result[0], result[1], result[2], result[3]));
|
|
47
|
+
} else {
|
|
48
|
+
int4 tmp = read_imagei(input, sampler, pos);
|
|
49
|
+
int* pixel = (int*)&tmp;
|
|
50
|
+
int result[4];
|
|
51
|
+
for(int i = 0; i < 4; ++i) {
|
|
52
|
+
if(removeChannel[i] == 0) {
|
|
53
|
+
result[writePos*sign + offset] = pixel[i];
|
|
54
|
+
++writePos;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
write_imagei(output, pos, (int4)(result[0], result[1], result[2], result[3]));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#ifdef fast_3d_image_writes
|
|
63
|
+
__kernel void channelConvert3D(
|
|
64
|
+
__read_only image3d_t input,
|
|
65
|
+
__write_only image3d_t output,
|
|
66
|
+
__private uchar4 removeChannelV,
|
|
67
|
+
__private char reverse,
|
|
68
|
+
__private int nrOfChannels
|
|
69
|
+
) {
|
|
70
|
+
|
|
71
|
+
int offset = 0;
|
|
72
|
+
int sign = 1;
|
|
73
|
+
if(reverse == 1) {
|
|
74
|
+
offset = (nrOfChannels-1) - (removeChannelV.x + removeChannelV.y + removeChannelV.z + removeChannelV.w);
|
|
75
|
+
sign = -1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
uchar* removeChannel = (uchar*)&removeChannelV;
|
|
79
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
80
|
+
int type = get_image_channel_data_type(input);
|
|
81
|
+
int writePos = 0;
|
|
82
|
+
if(type == CLK_FLOAT) {
|
|
83
|
+
float4 tmp = read_imagef(input, sampler, pos);
|
|
84
|
+
float* pixel = (float*)&tmp;
|
|
85
|
+
float result[4];
|
|
86
|
+
for(int i = 0; i < 4; ++i) {
|
|
87
|
+
if(removeChannel[i] == 0) {
|
|
88
|
+
result[writePos*sign + offset] = pixel[i];
|
|
89
|
+
++writePos;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
write_imagef(output, pos, (float4)(result[0], result[1], result[2], result[3]));
|
|
94
|
+
} else if(type == CLK_UNSIGNED_INT8 || type == CLK_UNSIGNED_INT16 || type == CLK_UNSIGNED_INT32) {
|
|
95
|
+
uint4 tmp = read_imageui(input, sampler, pos);
|
|
96
|
+
uint* pixel = (uint*)&tmp;
|
|
97
|
+
uint result[4];
|
|
98
|
+
for(int i = 0; i < 4; ++i) {
|
|
99
|
+
if(removeChannel[i] == 0) {
|
|
100
|
+
result[writePos*sign + offset] = pixel[i];
|
|
101
|
+
++writePos;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
write_imageui(output, pos, (uint4)(result[0], result[1], result[2], result[3]));
|
|
106
|
+
} else {
|
|
107
|
+
int4 tmp = read_imagei(input, sampler, pos);
|
|
108
|
+
int* pixel = (int*)&tmp;
|
|
109
|
+
int result[4];
|
|
110
|
+
for(int i = 0; i < 4; ++i) {
|
|
111
|
+
if(removeChannel[i] == 0) {
|
|
112
|
+
result[writePos*sign + offset] = pixel[i];
|
|
113
|
+
++writePos;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
write_imagei(output, pos, (int4)(result[0], result[1], result[2], result[3]));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
#else
|
|
121
|
+
#endif
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
|
|
2
|
+
|
|
3
|
+
__kernel void flip2D(
|
|
4
|
+
__read_only image2d_t input,
|
|
5
|
+
__write_only image2d_t output,
|
|
6
|
+
__private char flipHorizontal,
|
|
7
|
+
__private char flipVertical
|
|
8
|
+
) {
|
|
9
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
10
|
+
int2 targetPos = pos;
|
|
11
|
+
if(flipHorizontal == 1)
|
|
12
|
+
targetPos.x = get_global_size(0) - pos.x - 1;
|
|
13
|
+
if(flipVertical == 1)
|
|
14
|
+
targetPos.y = get_global_size(1) - pos.y - 1;
|
|
15
|
+
int dataType = get_image_channel_data_type(input);
|
|
16
|
+
if(dataType == CLK_FLOAT) {
|
|
17
|
+
write_imagef(output, targetPos, read_imagef(input, sampler, pos));
|
|
18
|
+
} else if(dataType == CLK_UNSIGNED_INT8 || dataType == CLK_UNSIGNED_INT16 || dataType == CLK_UNSIGNED_INT32) {
|
|
19
|
+
write_imageui(output, targetPos, read_imageui(input, sampler, pos));
|
|
20
|
+
} else {
|
|
21
|
+
write_imagei(output, targetPos, read_imagei(input, sampler, pos));
|
|
22
|
+
}
|
|
23
|
+
}
|