pyfast 4.12.0__cp36-abi3-win_amd64.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.
Files changed (307) hide show
  1. fast/README.md +41 -0
  2. fast/__init__.py +22 -0
  3. fast/bin/DirectML.dll +0 -0
  4. fast/bin/FAST.dll +0 -0
  5. fast/bin/InferenceEngineONNXRuntime.dll +0 -0
  6. fast/bin/InferenceEngineOpenVINO.dll +0 -0
  7. fast/bin/InferenceEngineTensorFlow.dll +0 -0
  8. fast/bin/InferenceEngineTensorRT.dll +0 -0
  9. fast/bin/JKQTCommonSharedLib_Release.dll +0 -0
  10. fast/bin/JKQTFastPlotterSharedLib_Release.dll +0 -0
  11. fast/bin/JKQTMathTextSharedLib_Release.dll +0 -0
  12. fast/bin/JKQTPlotterSharedLib_Release.dll +0 -0
  13. fast/bin/OpenCL.dll +0 -0
  14. fast/bin/OpenIGTLink.dll +0 -0
  15. fast/bin/Qt5Concurrent.dll +0 -0
  16. fast/bin/Qt5Core.dll +0 -0
  17. fast/bin/Qt5DBus.dll +0 -0
  18. fast/bin/Qt5Gui.dll +0 -0
  19. fast/bin/Qt5Multimedia.dll +0 -0
  20. fast/bin/Qt5MultimediaWidgets.dll +0 -0
  21. fast/bin/Qt5Network.dll +0 -0
  22. fast/bin/Qt5OpenGL.dll +0 -0
  23. fast/bin/Qt5PrintSupport.dll +0 -0
  24. fast/bin/Qt5SerialPort.dll +0 -0
  25. fast/bin/Qt5Sql.dll +0 -0
  26. fast/bin/Qt5Svg.dll +0 -0
  27. fast/bin/Qt5Test.dll +0 -0
  28. fast/bin/Qt5Widgets.dll +0 -0
  29. fast/bin/Qt5Xml.dll +0 -0
  30. fast/bin/UFFviewer.exe +0 -0
  31. fast/bin/_fast.pyd +0 -0
  32. fast/bin/brotlicommon.dll +0 -0
  33. fast/bin/brotlidec.dll +0 -0
  34. fast/bin/brotlienc.dll +0 -0
  35. fast/bin/cache.json +114134 -0
  36. fast/bin/dcmdata.dll +0 -0
  37. fast/bin/dcmimage.dll +0 -0
  38. fast/bin/dcmimgle.dll +0 -0
  39. fast/bin/dcmjpeg.dll +0 -0
  40. fast/bin/fast_configuration.txt +14 -0
  41. fast/bin/gna.dll +0 -0
  42. fast/bin/ijg12.dll +0 -0
  43. fast/bin/ijg16.dll +0 -0
  44. fast/bin/ijg8.dll +0 -0
  45. fast/bin/jxl.dll +0 -0
  46. fast/bin/jxl_cms.dll +0 -0
  47. fast/bin/jxl_threads.dll +0 -0
  48. fast/bin/libcrypto-1_1-x64.dll +0 -0
  49. fast/bin/libjpeg.dll +0 -0
  50. fast/bin/libopenslide-1.dll +0 -0
  51. fast/bin/libssl-1_1-x64.dll +0 -0
  52. fast/bin/oflog.dll +0 -0
  53. fast/bin/ofstd.dll +0 -0
  54. fast/bin/onnxruntime.dll +0 -0
  55. fast/bin/onnxruntime_providers_shared.dll +0 -0
  56. fast/bin/openvino.dll +0 -0
  57. fast/bin/openvino_auto_batch_plugin.dll +0 -0
  58. fast/bin/openvino_auto_plugin.dll +0 -0
  59. fast/bin/openvino_c.dll +0 -0
  60. fast/bin/openvino_gapi_preproc.dll +0 -0
  61. fast/bin/openvino_hetero_plugin.dll +0 -0
  62. fast/bin/openvino_intel_cpu_plugin.dll +0 -0
  63. fast/bin/openvino_intel_gna_plugin.dll +0 -0
  64. fast/bin/openvino_intel_gpu_plugin.dll +0 -0
  65. fast/bin/openvino_ir_frontend.dll +0 -0
  66. fast/bin/openvino_onnx_frontend.dll +0 -0
  67. fast/bin/openvino_paddle_frontend.dll +0 -0
  68. fast/bin/plugins.xml +24 -0
  69. fast/bin/realsense2.dll +0 -0
  70. fast/bin/runPipeline.exe +0 -0
  71. fast/bin/systemCheck.exe +0 -0
  72. fast/bin/tbb.dll +0 -0
  73. fast/bin/tbb_preview.dll +0 -0
  74. fast/bin/tbbbind.dll +0 -0
  75. fast/bin/tbbmalloc.dll +0 -0
  76. fast/bin/tbbmalloc_proxy.dll +0 -0
  77. fast/bin/tiff.dll +0 -0
  78. fast/bin/zlib.dll +0 -0
  79. fast/doc/bright-plotting-style.ini +66 -0
  80. fast/doc/dark-plotting-style.ini +66 -0
  81. fast/doc/fonts/UFL.txt +96 -0
  82. fast/doc/fonts/Ubuntu-Bold.ttf +0 -0
  83. fast/doc/fonts/Ubuntu-BoldItalic.ttf +0 -0
  84. fast/doc/fonts/Ubuntu-Italic.ttf +0 -0
  85. fast/doc/fonts/Ubuntu-Light.ttf +0 -0
  86. fast/doc/fonts/Ubuntu-LightItalic.ttf +0 -0
  87. fast/doc/fonts/Ubuntu-Medium.ttf +0 -0
  88. fast/doc/fonts/Ubuntu-MediumItalic.ttf +0 -0
  89. fast/doc/fonts/Ubuntu-Regular.ttf +0 -0
  90. fast/doc/fonts/UbuntuMono-Bold.ttf +0 -0
  91. fast/doc/fonts/UbuntuMono-BoldItalic.ttf +0 -0
  92. fast/doc/fonts/UbuntuMono-Italic.ttf +0 -0
  93. fast/doc/fonts/UbuntuMono-Regular.ttf +0 -0
  94. fast/doc/images/FAST_logo_square.png +0 -0
  95. fast/doc/images/fast_icon.ico +0 -0
  96. fast/doc/images/fast_icon.png +0 -0
  97. fast/entry_points.py +14 -0
  98. fast/fast.py +20057 -0
  99. fast/kernels/Algorithms/AirwaySegmentation/AirwaySegmentation.cl +85 -0
  100. fast/kernels/Algorithms/ApplyColormap/ApplyColormap.cl +146 -0
  101. fast/kernels/Algorithms/BinaryThresholding/BinaryThresholding2D.cl +61 -0
  102. fast/kernels/Algorithms/BinaryThresholding/BinaryThresholding3D.cl +61 -0
  103. fast/kernels/Algorithms/BlockMatching/BlockMatching.cl +257 -0
  104. fast/kernels/Algorithms/CenterlineExtraction/CenterlineExtraction.cl +153 -0
  105. fast/kernels/Algorithms/CoherentPointDrift/CoherentPointDrift.cl +0 -0
  106. fast/kernels/Algorithms/Color/ColorToGrayscale.cl +22 -0
  107. fast/kernels/Algorithms/Color/GrayscaleToColor.cl +19 -0
  108. fast/kernels/Algorithms/GaussianSmoothing/GaussianSmoothing2D.cl +35 -0
  109. fast/kernels/Algorithms/GaussianSmoothing/GaussianSmoothing3D.cl +75 -0
  110. fast/kernels/Algorithms/GradientVectorFlow/EulerGradientVectorFlow.cl +174 -0
  111. fast/kernels/Algorithms/GradientVectorFlow/MultigridGradientVectorFlow.cl +407 -0
  112. fast/kernels/Algorithms/HounsefieldConverter/HounsefieldConverter.cl +22 -0
  113. fast/kernels/Algorithms/ImageAdd/ImageAdd.cl +79 -0
  114. fast/kernels/Algorithms/ImageCaster/ImageCaster.cl +38 -0
  115. fast/kernels/Algorithms/ImageChannelConverter/ImageChannelConverter.cl +121 -0
  116. fast/kernels/Algorithms/ImageFlipper/ImageFlipper2D.cl +23 -0
  117. fast/kernels/Algorithms/ImageFlipper/ImageFlipper3D.cl +51 -0
  118. fast/kernels/Algorithms/ImageGradient/ImageGradient.cl +71 -0
  119. fast/kernels/Algorithms/ImageInverter/ImageInverter.cl +30 -0
  120. fast/kernels/Algorithms/ImageMultiply/ImageMultiply.cl +79 -0
  121. fast/kernels/Algorithms/ImagePatch/PatchStitcher2D.cl +22 -0
  122. fast/kernels/Algorithms/ImagePatch/PatchStitcher3D.cl +95 -0
  123. fast/kernels/Algorithms/ImageResampler/ImageResampler2D.cl +40 -0
  124. fast/kernels/Algorithms/ImageResampler/ImageResampler3D.cl +32 -0
  125. fast/kernels/Algorithms/ImageResizer/ImageResizer.cl +134 -0
  126. fast/kernels/Algorithms/ImageSharpening/ImageSharpening.cl +47 -0
  127. fast/kernels/Algorithms/ImageSlicer/ImageSlicer.cl +77 -0
  128. fast/kernels/Algorithms/ImageTransposer/ImageTransposer2D.cl +16 -0
  129. fast/kernels/Algorithms/ImageTransposer/ImageTransposer3D.cl +45 -0
  130. fast/kernels/Algorithms/IntensityClipping/IntensityClipping2D.cl +19 -0
  131. fast/kernels/Algorithms/IntensityClipping/IntensityClipping3D.cl +20 -0
  132. fast/kernels/Algorithms/IntensityNormalization/IntensityNormalization.cl +85 -0
  133. fast/kernels/Algorithms/IntensityNormalization/ZeroMeanUnitVariance.cl +76 -0
  134. fast/kernels/Algorithms/KalmanFilterModelSegmentation/AppearanceModels/RidgeEdge/RidgeEdgeModel.cl +81 -0
  135. fast/kernels/Algorithms/LabelModifier/LabelModifier.cl +20 -0
  136. fast/kernels/Algorithms/LaplacianOfGaussian/LaplacianOfGaussian2D.cl +27 -0
  137. fast/kernels/Algorithms/LevelSet/LevelSetSegmentation.cl +132 -0
  138. fast/kernels/Algorithms/LungSegmentation/LungSegmentation.cl +22 -0
  139. fast/kernels/Algorithms/MeshToSegmentation/MeshToSegmentation.cl +184 -0
  140. fast/kernels/Algorithms/Morphology/Dilation.cl +56 -0
  141. fast/kernels/Algorithms/Morphology/Erosion.cl +64 -0
  142. fast/kernels/Algorithms/NeuralNetwork/NeuralNetwork.cl +122 -0
  143. fast/kernels/Algorithms/NeuralNetwork/VertexTensorToSegmentation.cl +13 -0
  144. fast/kernels/Algorithms/NonLocalMeans/NonLocalMeans2D.cl +94 -0
  145. fast/kernels/Algorithms/SeededRegionGrowing/SeededRegionGrowing2D.cl +57 -0
  146. fast/kernels/Algorithms/SeededRegionGrowing/SeededRegionGrowing3D.cl +58 -0
  147. fast/kernels/Algorithms/Skeletonization/Skeletonization2D.cl +77 -0
  148. fast/kernels/Algorithms/SurfaceExtraction/SurfaceExtraction.cl +519 -0
  149. fast/kernels/Algorithms/SurfaceExtraction/SurfaceExtraction_no_3d_write.cl +739 -0
  150. fast/kernels/Algorithms/TemporalSmoothing/ImageMovingAverage.cl +66 -0
  151. fast/kernels/Algorithms/TemporalSmoothing/ImageWeightedMovingAverage.cl +74 -0
  152. fast/kernels/Algorithms/TissueSegmentation/TissueSegmentation.cl +18 -0
  153. fast/kernels/Algorithms/TubeSegmentationAndCenterlineExtraction/InverseGradientSegmentation.cl +203 -0
  154. fast/kernels/Algorithms/TubeSegmentationAndCenterlineExtraction/TubeSegmentationAndCenterlineExtraction.cl +566 -0
  155. fast/kernels/Algorithms/Ultrasound/EnvelopeAndLogCompressor.cl +45 -0
  156. fast/kernels/Algorithms/Ultrasound/ScanConverter.cl +76 -0
  157. fast/kernels/Algorithms/UltrasoundImageCropper/UltrasoundImageCropper.cl +31 -0
  158. fast/kernels/Algorithms/UltrasoundImageEnhancement/UltrasoundImageEnhancement.cl +27 -0
  159. fast/kernels/Algorithms/VectorMedianFilter/VectorMedianFilter.cl +31 -0
  160. fast/kernels/ImageFill.cl +30 -0
  161. fast/kernels/ImageMinMax.cl +196 -0
  162. fast/kernels/ImageSum.cl +170 -0
  163. fast/kernels/Tests/Algorithms/DoubleFilter.cl +7 -0
  164. fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.frag +8 -0
  165. fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.geom +69 -0
  166. fast/kernels/Visualization/BoundingBoxRenderer/BoundingBoxRenderer.vert +17 -0
  167. fast/kernels/Visualization/HeatmapRenderer/HeatmapRenderer.cl +51 -0
  168. fast/kernels/Visualization/ImagePyramidRenderer/ImagePyramidRenderer.frag +11 -0
  169. fast/kernels/Visualization/ImagePyramidRenderer/ImagePyramidRenderer.vert +15 -0
  170. fast/kernels/Visualization/ImageRenderer/ImageRenderer.vert +15 -0
  171. fast/kernels/Visualization/ImageRenderer/ImageRendererFLOAT.frag +18 -0
  172. fast/kernels/Visualization/ImageRenderer/ImageRendererINT.frag +18 -0
  173. fast/kernels/Visualization/ImageRenderer/ImageRendererUINT.frag +18 -0
  174. fast/kernels/Visualization/LineRenderer/LineRenderer.frag +8 -0
  175. fast/kernels/Visualization/LineRenderer/LineRenderer.geom +35 -0
  176. fast/kernels/Visualization/LineRenderer/LineRenderer.vert +20 -0
  177. fast/kernels/Visualization/LineRenderer/LineRenderer3D.frag +8 -0
  178. fast/kernels/Visualization/LineRenderer/LineRenderer3D.vert +20 -0
  179. fast/kernels/Visualization/LineRenderer/LineRendererJoints.frag +15 -0
  180. fast/kernels/Visualization/LineRenderer/LineRendererJoints.vert +24 -0
  181. fast/kernels/Visualization/SegmentationLabelRenderer/SegmentationLabelRenderer.frag +11 -0
  182. fast/kernels/Visualization/SegmentationLabelRenderer/SegmentationLabelRenderer.vert +16 -0
  183. fast/kernels/Visualization/SegmentationRenderer/SegmentationPyramidRenderer.frag +53 -0
  184. fast/kernels/Visualization/SegmentationRenderer/SegmentationRenderer.frag +52 -0
  185. fast/kernels/Visualization/SegmentationRenderer/SegmentationRenderer.vert +15 -0
  186. fast/kernels/Visualization/TextRenderer/TextRenderer.frag +11 -0
  187. fast/kernels/Visualization/TextRenderer/TextRenderer.vert +20 -0
  188. fast/kernels/Visualization/TriangleRenderer/TriangleRenderer.frag +49 -0
  189. fast/kernels/Visualization/TriangleRenderer/TriangleRenderer.vert +35 -0
  190. fast/kernels/Visualization/VectorFieldRenderer/VectorFieldColorRenderer.cl +30 -0
  191. fast/kernels/Visualization/VertexRenderer/VertexRenderer.frag +14 -0
  192. fast/kernels/Visualization/VertexRenderer/VertexRenderer.vert +23 -0
  193. fast/kernels/Visualization/View.cl +10 -0
  194. fast/kernels/Visualization/VolumeRenderer/AlphaBlendingVolumeRenderer.cl +211 -0
  195. fast/kernels/Visualization/VolumeRenderer/MaximumIntensityProjection.cl +139 -0
  196. fast/kernels/Visualization/VolumeRenderer/ThresholdVolumeRenderer.cl +178 -0
  197. fast/licenses/LICENSE +203 -0
  198. fast/licenses/MSVC/MSVC_redis_files_license.txt +96 -0
  199. fast/licenses/OpenIGTLink/LICENSE.txt +30 -0
  200. fast/licenses/OpenJPEG/LICENSE +39 -0
  201. fast/licenses/OpenSlide/COPYING.LESSER +504 -0
  202. fast/licenses/PCRE2/LICENCE.md +103 -0
  203. fast/licenses/SQLite/PUBLIC-DOMAIN.txt +9 -0
  204. fast/licenses/THIRD_PARTY_TF_C_LICENSES +7955 -0
  205. fast/licenses/cairo/COPYING +33 -0
  206. fast/licenses/cairo/COPYING-LGPL-2.1 +510 -0
  207. fast/licenses/cairo/COPYING-MPL-1.1 +470 -0
  208. fast/licenses/clarius/LICENSE +29 -0
  209. fast/licenses/dcmtk/COPYRIGHT +1034 -0
  210. fast/licenses/directml/LICENSE-CODE.txt +21 -0
  211. fast/licenses/directml/LICENSE.txt +48 -0
  212. fast/licenses/directml/ThirdPartyNotices.txt +103 -0
  213. fast/licenses/eigen/COPYING.APACHE +203 -0
  214. fast/licenses/eigen/COPYING.BSD +26 -0
  215. fast/licenses/eigen/COPYING.GPL +674 -0
  216. fast/licenses/eigen/COPYING.LGPL +502 -0
  217. fast/licenses/eigen/COPYING.MINPACK +51 -0
  218. fast/licenses/eigen/COPYING.MPL2 +373 -0
  219. fast/licenses/eigen/COPYING.README +18 -0
  220. fast/licenses/fast/LICENSE +25 -0
  221. fast/licenses/gdk-pixbuf/COPYING +502 -0
  222. fast/licenses/glib/COPYING +175 -0
  223. fast/licenses/hdf5/COPYING +106 -0
  224. fast/licenses/jkqtplotter/LICENSE +505 -0
  225. fast/licenses/jpegxl/LICENSE.brotli +19 -0
  226. fast/licenses/jpegxl/LICENSE.highway +201 -0
  227. fast/licenses/jpegxl/LICENSE.jpeg-xl +27 -0
  228. fast/licenses/jpegxl/LICENSE.skcms +29 -0
  229. fast/licenses/jpegxl/PATENTS +22 -0
  230. fast/licenses/libdicom/LICENSE +21 -0
  231. fast/licenses/libffi/LICENSE +21 -0
  232. fast/licenses/libjpeg-turbo/LICENSE.md +135 -0
  233. fast/licenses/libjpeg-turbo/README.ijg +260 -0
  234. fast/licenses/libpng/LICENSE +134 -0
  235. fast/licenses/libtiff/LICENSE.md +23 -0
  236. fast/licenses/libxml2/Copyright +24 -0
  237. fast/licenses/onnxruntime/LICENSE +21 -0
  238. fast/licenses/onnxruntime/Privacy.md +21 -0
  239. fast/licenses/onnxruntime/ThirdPartyNotices.txt +6156 -0
  240. fast/licenses/opencl/LICENSE +201 -0
  241. fast/licenses/openssl/LICENSE.txt +125 -0
  242. fast/licenses/openvino/Apache_license.txt +201 -0
  243. fast/licenses/openvino/EULA.htm +43 -0
  244. fast/licenses/openvino/EULA.rtf +61 -0
  245. fast/licenses/openvino/EULA.txt +163 -0
  246. fast/licenses/openvino/GNA SOFTWARE LICENSE AGREEMENT.txt +1 -0
  247. fast/licenses/openvino/Intel_Software_Development_Products.rtf +1217 -0
  248. fast/licenses/openvino/Intel_Software_Development_Products.txt +707 -0
  249. fast/licenses/openvino/LICENSE +201 -0
  250. fast/licenses/openvino/OpenVINOsupport.txt +12 -0
  251. fast/licenses/openvino/onednn_third-party-programs.txt +557 -0
  252. fast/licenses/openvino/readme.txt +60 -0
  253. fast/licenses/openvino/redist.txt +42 -0
  254. fast/licenses/openvino/runtime-third-party-programs.txt +1400 -0
  255. fast/licenses/openvino/tbb_third-party-programs.txt +230 -0
  256. fast/licenses/pixman/COPYING +42 -0
  257. fast/licenses/proxy-libintl/COPYING +482 -0
  258. fast/licenses/qt5/LICENSE.FDL +450 -0
  259. fast/licenses/qt5/LICENSE.GPL3-EXCEPT +704 -0
  260. fast/licenses/qt5/LICENSE.GPLv2 +292 -0
  261. fast/licenses/qt5/LICENSE.GPLv3 +686 -0
  262. fast/licenses/qt5/LICENSE.LGPLv21 +514 -0
  263. fast/licenses/qt5/LICENSE.LGPLv3 +175 -0
  264. fast/licenses/qt5/LICENSE.QT-LICENSE-AGREEMENT +1331 -0
  265. fast/licenses/realsense/LICENSE +202 -0
  266. fast/licenses/realsense/NOTICE +937 -0
  267. fast/licenses/semaphore/Semaphore_LICENSE.txt +17 -0
  268. fast/licenses/tiff/COPYRIGHT +21 -0
  269. fast/licenses/uthash/LICENSE +21 -0
  270. fast/licenses/zip/UNLICENSE +26 -0
  271. fast/licenses/zlib/README +115 -0
  272. fast/licenses/zlib-ng/LICENSE.md +19 -0
  273. fast/pipelines/uff_viewer/colormap_and_reject.fpl +26 -0
  274. fast/pipelines/uff_viewer/default.fpl +9 -0
  275. fast/pipelines/uff_viewer/non_local_means.fpl +34 -0
  276. fast/plugins/audio/qtaudio_wasapi.dll +0 -0
  277. fast/plugins/audio/qtaudio_windows.dll +0 -0
  278. fast/plugins/bearer/qgenericbearer.dll +0 -0
  279. fast/plugins/generic/qtuiotouchplugin.dll +0 -0
  280. fast/plugins/iconengines/qsvgicon.dll +0 -0
  281. fast/plugins/imageformats/qgif.dll +0 -0
  282. fast/plugins/imageformats/qicns.dll +0 -0
  283. fast/plugins/imageformats/qico.dll +0 -0
  284. fast/plugins/imageformats/qjpeg.dll +0 -0
  285. fast/plugins/imageformats/qsvg.dll +0 -0
  286. fast/plugins/imageformats/qtga.dll +0 -0
  287. fast/plugins/imageformats/qtiff.dll +0 -0
  288. fast/plugins/imageformats/qwbmp.dll +0 -0
  289. fast/plugins/imageformats/qwebp.dll +0 -0
  290. fast/plugins/mediaservice/dsengine.dll +0 -0
  291. fast/plugins/mediaservice/qtmedia_audioengine.dll +0 -0
  292. fast/plugins/mediaservice/wmfengine.dll +0 -0
  293. fast/plugins/platforms/qdirect2d.dll +0 -0
  294. fast/plugins/platforms/qminimal.dll +0 -0
  295. fast/plugins/platforms/qoffscreen.dll +0 -0
  296. fast/plugins/platforms/qwindows.dll +0 -0
  297. fast/plugins/platformthemes/qxdgdesktopportal.dll +0 -0
  298. fast/plugins/playlistformats/qtmultimedia_m3u.dll +0 -0
  299. fast/plugins/printsupport/windowsprintersupport.dll +0 -0
  300. fast/plugins/sqldrivers/qsqlite.dll +0 -0
  301. fast/plugins/sqldrivers/qsqlodbc.dll +0 -0
  302. fast/plugins/styles/qwindowsvistastyle.dll +0 -0
  303. pyfast-4.12.0.dist-info/METADATA +81 -0
  304. pyfast-4.12.0.dist-info/RECORD +307 -0
  305. pyfast-4.12.0.dist-info/WHEEL +5 -0
  306. pyfast-4.12.0.dist-info/entry_points.txt +5 -0
  307. pyfast-4.12.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,184 @@
1
+ // http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
2
+
3
+ int get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y,
4
+ float p2_x, float p2_y, float p3_x, float p3_y, float *i_x, float *i_y)
5
+ {
6
+ float epsilon = 0.001f;
7
+
8
+ float s02_x, s02_y, s10_x, s10_y, s32_x, s32_y, s_numer, t_numer, denom, t;
9
+ s10_x = p1_x - p0_x;
10
+ s10_y = p1_y - p0_y;
11
+ s32_x = p3_x - p2_x;
12
+ s32_y = p3_y - p2_y;
13
+
14
+ denom = s10_x * s32_y - s32_x * s10_y;
15
+ if (denom == 0)
16
+ return 0; // Collinear
17
+ bool denomPositive = denom > 0;
18
+
19
+ s02_x = p0_x - p2_x;
20
+ s02_y = p0_y - p2_y;
21
+ s_numer = s10_x * s02_y - s10_y * s02_x;
22
+ if ((s_numer < epsilon) == denomPositive)
23
+ return 0; // No collision
24
+
25
+ t_numer = s32_x * s02_y - s32_y * s02_x;
26
+ if ((t_numer < epsilon) == denomPositive)
27
+ return 0; // No collision
28
+
29
+ if (((s_numer > denom) == denomPositive) || ((t_numer > denom) == denomPositive))
30
+ return 0; // No collision
31
+ // Collision detected
32
+ t = t_numer / denom;
33
+ *i_x = p0_x + (t * s10_x);
34
+ *i_y = p0_y + (t * s10_y);
35
+
36
+ return 1;
37
+ }
38
+
39
+ __kernel void mesh_to_segmentation_2d(
40
+ __global float* coordinates,
41
+ __global uint2* lines,
42
+ __private uint nrOfLines,
43
+ __write_only image2d_t segmentation,
44
+ __private float spacingX,
45
+ __private float spacingY
46
+ ) {
47
+
48
+ const int2 pos = {get_global_id(0), get_global_id(1)};
49
+
50
+ // For each line, check if ray (arbitrary direction) from this pixel intersects
51
+ // Count number of intersections, if even: not inside, if odd: inside
52
+ int intersections = 0;
53
+ float x1 = pos.x*spacingX;
54
+ float y1 = pos.y*spacingY;
55
+ const float threshold = 0.00000001;
56
+ // x2 and y2 is 0
57
+ float y2 = y1;
58
+ for(int i = 0; i < nrOfLines; ++i) {
59
+ // https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
60
+ // http://geomalgorithms.com/a03-_inclusion.html
61
+ // Find intersection point
62
+ float3 coordinate3 = vload3(lines[i].x, coordinates);
63
+ float3 coordinate4 = vload3(lines[i].y, coordinates);
64
+ float x3 = coordinate3.x;
65
+ float y3 = coordinate3.y;
66
+ float x4 = coordinate4.x;
67
+ float y4 = coordinate4.y;
68
+
69
+ // Order edge points so that it always point downwards
70
+ if(y3 > y4) {
71
+ // swap y
72
+ float tmp = y4;
73
+ y4 = y3;
74
+ y3 = tmp;
75
+
76
+ // swap x
77
+ tmp = x4;
78
+ x4 = x3;
79
+ x3 = tmp;
80
+ }
81
+
82
+ if(y3 == y4) {
83
+ // Horizontal edge, drop
84
+ continue;
85
+ }
86
+
87
+ float x, y;
88
+ if(get_line_intersection(x1, y1, 0, y2, x3, y3, x4, y4, &x, &y) == 1) {
89
+ // Have we hit an edge point?
90
+ if(fabs(x-x4) < threshold && fabs(y-y4) < threshold) { // Through a top point
91
+ //++intersections;
92
+ } else if(fabs(x-x3) < threshold && fabs(y-y3) < threshold) { // Through a bottom point
93
+ ++intersections;
94
+ } else { // Passes through the middle of the line
95
+ ++intersections;
96
+ }
97
+ }
98
+ }
99
+
100
+ write_imageui(segmentation, pos, intersections % 2 == 0 ? 0:1);
101
+ }
102
+
103
+ int rayIntersectsTriangle(float3 p, float3 d, float3 v0, float3 v1, float3 v2) {
104
+
105
+ float3 e1,e2,h,s,q;
106
+ float a,f,u,v;
107
+ e1 = v1 - v0;
108
+ e2 = v2 - v0;
109
+
110
+ h = cross(d, e2);
111
+ a = dot(e1,h);
112
+
113
+ if (a > -0.00000000001f && a < 0.00000000001f)
114
+ return 0;
115
+
116
+ f = 1.0f/a;
117
+ s = p - v0;
118
+ u = f * (dot(s,h));
119
+
120
+ if (u < 0.0 || u > 1.0)
121
+ return 0;
122
+
123
+ q = cross(s,e1);
124
+ v = f * dot(d,q);
125
+
126
+ if (v < 0.0 || u + v > 1.0)
127
+ return 0;
128
+
129
+ // at this stage we can compute t to find out where
130
+ // the intersection point is on the line
131
+ float t = f * dot(e2,q);
132
+
133
+ if (t > 0.00000001f) { // ray intersection
134
+ return 1;
135
+
136
+ } else { // this means that there is a line intersection
137
+ // but not a ray intersection
138
+ return 0;
139
+ }
140
+
141
+ }
142
+
143
+ __kernel void mesh_to_segmentation_3d(
144
+ __global float* coordinates,
145
+ __global uint* triangles,
146
+ __private int nrOfTriangles,
147
+ __global uchar* segmentation,
148
+ __private float spacingX,
149
+ __private float spacingY,
150
+ __private float spacingZ
151
+ ) {
152
+ const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
153
+
154
+
155
+ // For each triangle, check if ray (arbitrary direction) from this pixel intersects
156
+ // See: http://geomalgorithms.com/a06-_intersect-2.html#intersect3D_RayTriangle()
157
+ // Count number of intersections, if even: not inside, if odd: inside
158
+ int intersections = 0;
159
+
160
+ // Ray start point
161
+ float3 P0 = {pos.x*spacingX, pos.y*spacingY, pos.z*spacingZ};
162
+ if(P0.y == 0) {
163
+ // There is a strange problem if y component is exactly zero
164
+ // This is a hack to avoid this
165
+ P0.y = 0.00001;
166
+ }
167
+
168
+ // Set arbitrarty direction
169
+ float3 P1 = P0;
170
+ P1.x += 0.1;
171
+
172
+ for(int i = 0; i < nrOfTriangles; ++i) {
173
+ const uint3 triangle = vload3(i, triangles);
174
+ const float3 u = vload3(triangle.x, coordinates);
175
+ const float3 v = vload3(triangle.y, coordinates);
176
+ const float3 w = vload3(triangle.z, coordinates);
177
+
178
+ if(rayIntersectsTriangle(P0, P1, u, v, w) >= 1) {
179
+ intersections += 1;
180
+ }
181
+ }
182
+
183
+ segmentation[pos.x + pos.y*get_global_size(0) + pos.z*get_global_size(0)*get_global_size(1)] = intersections % 2 == 0 ? 0:1;
184
+ }
@@ -0,0 +1,56 @@
1
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
2
+ #define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
3
+
4
+ __kernel void dilate3D(
5
+ __read_only image3d_t volume,
6
+ #ifdef fast_3d_image_writes
7
+ __write_only image3d_t result,
8
+ #else
9
+ __global uchar * result,
10
+ #endif
11
+ __private int size
12
+ ) {
13
+ int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
14
+
15
+ if(read_imageui(volume, sampler, pos).x == 1) {
16
+ for(int a = -size; a <= size ; a++) {
17
+ for(int b = -size; b <= size ; b++) {
18
+ for(int c = -size; c <= size ; c++) {
19
+ int4 n = (int4)(a,b,c,0);
20
+ if(length(convert_float4(n)) > size)
21
+ continue;
22
+ #ifdef fast_3d_image_writes
23
+ write_imageui(result, pos + n, 1);
24
+ #else
25
+ // Check if in bounds
26
+ int4 nPos = pos + n;
27
+ if(nPos.x >= 0 && nPos.y >= 0 && nPos.z >= 0 &&
28
+ nPos.x < get_global_size(0) && nPos.y < get_global_size(1) && nPos.z < get_global_size(2))
29
+ result[LPOS(nPos)] = 1;
30
+ #endif
31
+ }
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ __kernel void dilate2D(
38
+ __read_only image2d_t volume,
39
+ __write_only image2d_t result,
40
+ __private int size
41
+ ) {
42
+ const int2 pos = {get_global_id(0), get_global_id(1)};
43
+ const int width = get_image_width(result);
44
+ const int height = get_image_height(result);
45
+
46
+ if(read_imageui(volume, sampler, pos).x == 1) {
47
+ char write = 0;
48
+ for(int a = -size; a <= size ; a++) {
49
+ for(int b = -size; b <= size ; b++) {
50
+ int2 n = (int2)(a,b);
51
+ if(length(convert_float2(n)) <= size && pos.x+a >= 0 && pos.x+a < width && pos.y+b >= 0 && pos.y+b < height)
52
+ write_imageui(result, pos + n, 1);
53
+ }
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,64 @@
1
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
2
+ #define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
3
+
4
+
5
+ __kernel void erode3D(
6
+ __read_only image3d_t volume,
7
+ #ifdef fast_3d_image_writes
8
+ __write_only image3d_t result,
9
+ #else
10
+ __global uchar * result,
11
+ #endif
12
+ __private int size
13
+ ) {
14
+ int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
15
+
16
+ int value = read_imageui(volume, sampler, pos).x;
17
+ if(value == 1) {
18
+ bool keep = true;
19
+ for(int a = -size; a <= size; a++) {
20
+ for(int b = -size; b <= size; b++) {
21
+ for(int c = -size; c <= size; c++) {
22
+ int4 n = (int4)(a,b,c,0);
23
+ if(length(convert_float4(n)) > size)
24
+ continue;
25
+ keep = (read_imageui(volume, sampler, pos + n).x == 1 && keep);
26
+ }
27
+ }
28
+ }
29
+ #ifdef fast_3d_image_writes
30
+ write_imageui(result, pos, keep ? 1 : 0);
31
+ } else {
32
+ write_imageui(result, pos, 0);
33
+ }
34
+ #else
35
+ result[LPOS(pos)] = keep ? 1 : 0;
36
+ } else {
37
+ result[LPOS(pos)] = 0;
38
+ }
39
+ #endif
40
+ }
41
+
42
+ __kernel void erode2D(
43
+ __read_only image2d_t volume,
44
+ __write_only image2d_t result,
45
+ __private int size
46
+ ) {
47
+ const int2 pos = {get_global_id(0), get_global_id(1)};
48
+
49
+ int value = read_imageui(volume, sampler, pos).x;
50
+ if(value == 1) {
51
+ bool keep = true;
52
+ for(int a = -size; a <= size; a++) {
53
+ for(int b = -size; b <= size; b++) {
54
+ int2 n = (int2)(a,b);
55
+ if(length(convert_float2(n)) > size)
56
+ continue;
57
+ keep = (read_imageui(volume, sampler, pos + n).x == 1 && keep);
58
+ }
59
+ }
60
+ write_imageui(result, pos, keep ? 1 : 0);
61
+ } else {
62
+ write_imageui(result, pos, 0);
63
+ }
64
+ }
@@ -0,0 +1,122 @@
1
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
2
+
3
+ __kernel void normalize2DInput(
4
+ __read_only image2d_t input,
5
+ __global float* output,
6
+ __private float scaleFactor,
7
+ __private float mean,
8
+ __private float std,
9
+ __private int signedInputNormalization,
10
+ __private int horizontalFlip,
11
+ __private int channels,
12
+ __private float minIntensity,
13
+ __private float maxIntensity,
14
+ __private int clipIntensity,
15
+ __private int channelFirst
16
+ ) {
17
+
18
+ const int2 pos = {get_global_id(0), get_global_id(1)};
19
+ const int dataType = get_image_channel_data_type(input);
20
+ float4 value;
21
+ if(dataType == CLK_FLOAT) {
22
+ value = read_imagef(input, sampler, pos);
23
+ } else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
24
+ value = convert_float4(read_imagei(input, sampler, pos));
25
+ } else {
26
+ value = convert_float4(read_imageui(input, sampler, pos));
27
+ }
28
+
29
+ if(clipIntensity)
30
+ value = clamp(value, minIntensity, maxIntensity);
31
+ value = (value - mean)/std;
32
+ value = value*scaleFactor;
33
+ if(signedInputNormalization) {
34
+ value = value*2 - 1;
35
+ }
36
+
37
+ int x;
38
+ if(horizontalFlip == 1) {
39
+ x = (get_global_size(0) - pos.x - 1);
40
+ } else {
41
+ x = pos.x;
42
+ }
43
+ const int width = get_global_size(0);
44
+ const int height = get_global_size(1);
45
+ if(channelFirst == 0) {
46
+ int position = (pos.x + pos.y*width)*channels;
47
+ output[position] = value.x;
48
+ if(channels > 1)
49
+ output[position+1] = value.y;
50
+ if(channels > 2)
51
+ output[position+2] = value.z;
52
+ if(channels > 3)
53
+ output[position+3] = value.w;
54
+ } else {
55
+ int position = pos.x + pos.y*width;
56
+ output[position] = value.x;
57
+ if(channels > 1)
58
+ output[position + 1*width*height] = value.y;
59
+ if(channels > 2)
60
+ output[position + 2*width*height] = value.z;
61
+ if(channels > 3)
62
+ output[position + 3*width*height] = value.w;
63
+ }
64
+ }
65
+
66
+ __kernel void normalize3DInput(
67
+ __read_only image3d_t input,
68
+ __global float* output,
69
+ __private float scaleFactor,
70
+ __private float mean,
71
+ __private float std,
72
+ __private int signedInputNormalization,
73
+ __private int horizontalFlip,
74
+ __private int channels,
75
+ __private float minIntensity,
76
+ __private float maxIntensity,
77
+ __private int clipIntensity,
78
+ __private int channelFirst
79
+ ) {
80
+
81
+ const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
82
+ const int dataType = get_image_channel_data_type(input);
83
+ float4 value;
84
+ if(dataType == CLK_FLOAT) {
85
+ value = read_imagef(input, sampler, pos);
86
+ } else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
87
+ value = convert_float4(read_imagei(input, sampler, pos));
88
+ } else {
89
+ value = convert_float4(read_imageui(input, sampler, pos));
90
+ }
91
+
92
+ if(clipIntensity)
93
+ value = clamp(value, minIntensity, maxIntensity);
94
+ value = (value - mean)/std;
95
+ value = value*scaleFactor;
96
+ if(signedInputNormalization) {
97
+ value = value*2 - 1;
98
+ }
99
+
100
+ const int width = get_global_size(0);
101
+ const int height = get_global_size(1);
102
+ const int depth = get_global_size(2);
103
+ if(channelFirst == 0) {
104
+ int position = (pos.x + pos.y*width + pos.z*width*height)*channels;
105
+ output[position] = value.x;
106
+ if(channels > 1)
107
+ output[position+1] = value.y;
108
+ if(channels > 2)
109
+ output[position+2] = value.z;
110
+ if(channels > 3)
111
+ output[position+3] = value.w;
112
+ } else {
113
+ int position = pos.x + pos.y*width + pos.z*width*height;
114
+ output[position] = value.x;
115
+ if(channels > 1)
116
+ output[position + 1*width*height*depth] = value.y;
117
+ if(channels > 2)
118
+ output[position + 2*width*height*depth] = value.z;
119
+ if(channels > 3)
120
+ output[position + 3*width*height*depth] = value.w;
121
+ }
122
+ }
@@ -0,0 +1,13 @@
1
+ __const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
2
+
3
+ __kernel void writeSegmentation(
4
+ __write_only image2d_t current,
5
+ __read_only image2d_t new,
6
+ int label
7
+ ) {
8
+ const int2 pos = {get_global_id(0), get_global_id(1)};
9
+
10
+ if(read_imageui(new, sampler, pos).x > 0) {
11
+ write_imageui(current, pos, label);
12
+ }
13
+ }
@@ -0,0 +1,94 @@
1
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
2
+
3
+ float calculateDiff(__read_only image2d_t imageInput, int2 pos1, int2 pos2, int filterSize, int iteration) {
4
+ float res = 0.0f;
5
+ for(int offset_x = -FILTER_SIZE; offset_x <= FILTER_SIZE; ++offset_x) {
6
+ for(int offset_y = -FILTER_SIZE; offset_y <= FILTER_SIZE; ++offset_y) {
7
+ int2 offset = {offset_x, offset_y};
8
+ float diff = (float)read_imageui(imageInput, sampler, pos1 + offset).x/255.0f - (float)read_imageui(imageInput, sampler, pos2 + offset).x/255.0f;
9
+ diff = diff*diff;
10
+ res += diff;
11
+ }
12
+ }
13
+ return res;
14
+ }
15
+
16
+ uchar findMedian(uchar array[], const int size) {
17
+ for(uint i = 0; i < size; ++i) {
18
+ for(uint j = 0; j < i; ++j) {
19
+ if(array[i] > array[j]) {
20
+ uchar tmp = array[i];
21
+ array[i] = array[j];
22
+ array[j] = tmp;
23
+ }
24
+ }
25
+ }
26
+
27
+ if(size % 2 == 0) {
28
+ return (uchar)round((array[size / 2] + array[size / 2 + 1])*0.5f);
29
+ } else {
30
+ return array[size / 2];
31
+ }
32
+ }
33
+
34
+ __kernel void preprocess(
35
+ __read_only image2d_t input,
36
+ __write_only image2d_t output
37
+ ) {
38
+ const int2 pos = {get_global_id(0), get_global_id(1)};
39
+ // Read neighborhood to thread
40
+ uchar elements[25];
41
+ int counter = 0;
42
+ for(int a = -2; a <= 2; ++a) {
43
+ for(int b = -2; b <= 2; ++b) {
44
+ elements[counter] = read_imageui(input, sampler, pos + (int2)(a,b)).x;
45
+ ++counter;
46
+ }
47
+ }
48
+ uchar median = findMedian(elements, 25);
49
+
50
+ const float threshold = 150.0f; // TODO Set this threshold in a smarter way
51
+ const float current = read_imageui(input, sampler, pos).x;
52
+ uchar newPixel = current - max((float)median - current - threshold, 0.0f);
53
+ write_imageui(output, pos, newPixel);
54
+ }
55
+
56
+ __kernel void nonLocalMeansFilter(
57
+ __read_only image2d_t imageInput,
58
+ __write_only image2d_t imageOutput,
59
+ __private int searchSize,
60
+ __private int filterSize,
61
+ __private float parameterH,
62
+ __private int iteration
63
+ ) {
64
+ const int2 pos = {get_global_id(0), get_global_id(1)};
65
+ float sumBottom = 0.0f;
66
+ float sumTop = 0.0f;
67
+
68
+ // Loop over search region
69
+ for(int searchOffsetX = -SEARCH_SIZE; searchOffsetX <= SEARCH_SIZE; ++searchOffsetX) {
70
+ for(int searchOffsetY = -SEARCH_SIZE; searchOffsetY <= SEARCH_SIZE; ++searchOffsetY) {
71
+ int2 searchOffsetAtScale = {searchOffsetX*(iteration+1), searchOffsetY*(iteration+1)};
72
+ float diff = calculateDiff(imageInput, pos, pos + searchOffsetAtScale, filterSize, iteration);
73
+ diff = native_exp(-diff/(2.0f*parameterH*parameterH));// / (2.0f*parameterH*parameterH);
74
+ sumBottom += diff;
75
+ sumTop += diff*read_imageui(imageInput, sampler, pos + searchOffsetAtScale).x/255.0f;
76
+ }
77
+ }
78
+
79
+ write_imageui(imageOutput, pos, (uchar)round(clamp((sumTop/sumBottom)*255.0f, 0.0f, 255.0f)));
80
+ }
81
+
82
+ __kernel void multiplyWithInput(
83
+ __read_only image2d_t inputImage,
84
+ __read_only image2d_t NLMImage,
85
+ __write_only image2d_t output,
86
+ __private float multiplicationWeight
87
+ ) {
88
+
89
+ const int2 pos = {get_global_id(0), get_global_id(1)};
90
+ float inputValue = read_imageui(inputImage, sampler, pos).x;
91
+ float nlmValue = read_imageui(NLMImage, sampler, pos).x;
92
+
93
+ write_imageui(output, pos, (uchar)round(sqrt((inputValue*multiplicationWeight + nlmValue*(1.0f-multiplicationWeight))*nlmValue)));
94
+ }
@@ -0,0 +1,57 @@
1
+
2
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
3
+
4
+ #ifdef TYPE_FLOAT
5
+ #define READ_IMAGE(image, pos) read_imagef(image, sampler, pos).x
6
+ #elif TYPE_INT
7
+ #define READ_IMAGE(image, pos) (float)read_imagei(image, sampler, pos).x
8
+ #else
9
+ #define READ_IMAGE(image, pos) (float)read_imageui(image, sampler, pos).x
10
+ #endif
11
+
12
+ __kernel void seededRegionGrowing(
13
+ __read_only image2d_t image,
14
+ __global char* segmentation,
15
+ __global char* stopGrowing,
16
+ __private float min,
17
+ __private float max
18
+ ) {
19
+ const int2 pos = {get_global_id(0), get_global_id(1)};
20
+ const uint linearPos = pos.x + pos.y*get_global_size(0);
21
+
22
+ // Define neighborhood offsets
23
+ int2 offset[8] = {
24
+ {1,0},
25
+ {0,1},
26
+ {1,1},
27
+ {-1,0},
28
+ {0,-1},
29
+ {-1,-1},
30
+ {-1,1},
31
+ {1,-1}
32
+ };
33
+
34
+ if(segmentation[linearPos] == 2) { // pixel is in queue
35
+ float intensity = READ_IMAGE(image, pos);
36
+ if(intensity >= min && intensity <= max) {
37
+ segmentation[linearPos] = 1; // add pixel to segmentation
38
+ // Add neighbor pixels to queue
39
+ for(int i = 0; i < 8; i++) {
40
+ // Out of bounds check
41
+ int2 neighborPos = pos + offset[i];
42
+ if(neighborPos.x < 0 || neighborPos.y < 0 ||
43
+ neighborPos.x >= get_global_size(0) || neighborPos.y >= get_global_size(1))
44
+ continue;
45
+ uint neighborLinearPos = neighborPos.x + neighborPos.y*get_global_size(0);
46
+ if(segmentation[neighborLinearPos] == 0) {
47
+ segmentation[neighborLinearPos] = 2; // add to queue
48
+ stopGrowing[0] = 0;
49
+ }
50
+ }
51
+ } else {
52
+ segmentation[linearPos] = 0; // Remove pixel
53
+ }
54
+ }
55
+ }
56
+
57
+
@@ -0,0 +1,58 @@
1
+
2
+ __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_NONE;
3
+
4
+ #ifdef TYPE_FLOAT
5
+ #define READ_IMAGE(image, pos) read_imagef(image, sampler, pos).x
6
+ #elif TYPE_INT
7
+ #define READ_IMAGE(image, pos) (float)read_imagei(image, sampler, pos).x
8
+ #else
9
+ #define READ_IMAGE(image, pos) (float)read_imageui(image, sampler, pos).x
10
+ #endif
11
+
12
+
13
+
14
+ __kernel void seededRegionGrowing(
15
+ __read_only image3d_t image,
16
+ __global char* segmentation,
17
+ __global char* stopGrowing,
18
+ __private float min,
19
+ __private float max
20
+ ) {
21
+ const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
22
+ const uint linearPos = pos.x + pos.y*get_global_size(0) + pos.z*get_global_size(0)*get_global_size(1);
23
+
24
+ const int4 offsets[6] = {
25
+ {0,0,1,0},
26
+ {0,1,0,0},
27
+ {1,0,0,0},
28
+ {0,0,-1,0},
29
+ {0,-1,0,0},
30
+ {-1,0,0,0},
31
+ };
32
+
33
+ if(segmentation[linearPos] == 2) { // pixel is in queue
34
+ float intensity = READ_IMAGE(image, pos);
35
+ if(intensity >= min && intensity <= max) {
36
+ segmentation[linearPos] = 1; // add pixel to segmentation
37
+ // Add neighbor pixels to queue
38
+ for(int i = 0; i < 6; i++) {
39
+ // Out of bounds check. TODO something more efficient
40
+ int4 neighborPos = pos + offsets[i];
41
+ if(neighborPos.x < 0 || neighborPos.y < 0 || neighborPos.z < 0 ||
42
+ neighborPos.x >= get_global_size(0) || neighborPos.y >= get_global_size(1) ||
43
+ neighborPos.z >= get_global_size(2))
44
+ continue;
45
+ uint neighborLinearPos = neighborPos.x + neighborPos.y*get_global_size(0) +
46
+ neighborPos.z*get_global_size(0)*get_global_size(1);
47
+ if(segmentation[neighborLinearPos] == 0) {
48
+ segmentation[neighborLinearPos] = 2; // add to queue
49
+ stopGrowing[0] = 0;
50
+ }
51
+ }
52
+ } else {
53
+ segmentation[linearPos] = 0; // Remove pixel
54
+ }
55
+ }
56
+ }
57
+
58
+