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,566 @@
|
|
|
1
|
+
__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
|
|
2
|
+
__constant sampler_t interpolationSampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR;
|
|
3
|
+
__constant sampler_t hpSampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;
|
|
4
|
+
|
|
5
|
+
#define LPOS(pos) pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1)
|
|
6
|
+
|
|
7
|
+
#ifdef VECTORS_16BIT
|
|
8
|
+
//#define UNORM16_TO_FLOAT(v) (float)v / 65535.0f
|
|
9
|
+
//#define TDF_TYPE ushort
|
|
10
|
+
//#define FLOAT_TO_UNORM16(v) convert_ushort_sat_rte(v * 65535.0f)
|
|
11
|
+
#define UNORM16_TO_FLOAT(v) v
|
|
12
|
+
#define FLOAT_TO_UNORM16(v) v
|
|
13
|
+
#define TDF_TYPE float
|
|
14
|
+
|
|
15
|
+
#define VECTOR_FIELD_TYPE short
|
|
16
|
+
#define FLOAT_TO_SNORM16_3(vector) convert_short3_sat_rte(vector * 32767.0f)
|
|
17
|
+
|
|
18
|
+
#else
|
|
19
|
+
#define UNORM16_TO_FLOAT(v) v
|
|
20
|
+
#define FLOAT_TO_UNORM16(v) v
|
|
21
|
+
#define TDF_TYPE float
|
|
22
|
+
|
|
23
|
+
#define VECTOR_FIELD_TYPE float
|
|
24
|
+
#define FLOAT_TO_SNORM16_3(vector) vector
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
float4 readImageToFloat(
|
|
28
|
+
__read_only image3d_t volume,
|
|
29
|
+
int4 position
|
|
30
|
+
) {
|
|
31
|
+
int dataType = get_image_channel_data_type(volume);
|
|
32
|
+
float4 value;
|
|
33
|
+
if(dataType == CLK_FLOAT) {
|
|
34
|
+
value = read_imagef(volume, sampler, position).x;
|
|
35
|
+
} else if(dataType == CLK_SIGNED_INT8 || dataType == CLK_SIGNED_INT16 || dataType == CLK_SIGNED_INT32) {
|
|
36
|
+
value = convert_float4(read_imagei(volume, sampler, position));
|
|
37
|
+
} else {
|
|
38
|
+
value = convert_float4(read_imageui(volume, sampler, position));
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
float3 gradient(
|
|
44
|
+
__read_only image3d_t volume, // Volume to perform gradient on
|
|
45
|
+
int4 pos, // Position to perform gradient on
|
|
46
|
+
int volumeComponent, // The volume component to perform gradient on: 0, 1 or 2
|
|
47
|
+
int dimensions, // The number of dimensions to perform gradient in: 1, 2 or 3
|
|
48
|
+
float3 spacing // Image spacing
|
|
49
|
+
) {
|
|
50
|
+
float f100, f_100, f010 = 0, f0_10 = 0, f001 = 0, f00_1 = 0;
|
|
51
|
+
switch(volumeComponent) {
|
|
52
|
+
case 0:
|
|
53
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).x;
|
|
54
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).x;
|
|
55
|
+
if(dimensions > 1) {
|
|
56
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).x;
|
|
57
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).x;
|
|
58
|
+
}
|
|
59
|
+
if(dimensions > 2) {
|
|
60
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).x;
|
|
61
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).x;
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case 1:
|
|
65
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).y;
|
|
66
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).y;
|
|
67
|
+
if(dimensions > 1) {
|
|
68
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).y;
|
|
69
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).y;
|
|
70
|
+
}
|
|
71
|
+
if(dimensions > 2) {
|
|
72
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).y;
|
|
73
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).y;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case 2:
|
|
77
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).z;
|
|
78
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).z;
|
|
79
|
+
if(dimensions > 1) {
|
|
80
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).z;
|
|
81
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).z;
|
|
82
|
+
}
|
|
83
|
+
if(dimensions > 2) {
|
|
84
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).z;
|
|
85
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).z;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
float3 gradient = {
|
|
91
|
+
(f100-f_100)/(2.0f),
|
|
92
|
+
(f010-f0_10)/(2.0f),
|
|
93
|
+
(f001-f00_1)/(2.0f)
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Keep original length
|
|
97
|
+
float gradientLength = length(gradient);
|
|
98
|
+
gradient /= spacing;
|
|
99
|
+
gradient = gradientLength*normalize(gradient);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
return gradient;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
float3 gradientNormalized(
|
|
106
|
+
__read_only image3d_t volume, // Volume to perform gradient on, this volume is vector field
|
|
107
|
+
int4 pos, // Position to perform gradient on
|
|
108
|
+
int volumeComponent, // The volume component to perform gradient on: 0, 1 or 2
|
|
109
|
+
int dimensions, // The number of dimensions to perform gradient in: 1, 2 or 3
|
|
110
|
+
float3 spacing // Image spacing
|
|
111
|
+
) {
|
|
112
|
+
float f100, f_100, f010 = 0, f0_10 = 0, f001 = 0, f00_1 = 0;
|
|
113
|
+
switch(volumeComponent) {
|
|
114
|
+
case 0:
|
|
115
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).x;
|
|
116
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).x;
|
|
117
|
+
if(dimensions > 1) {
|
|
118
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).x;
|
|
119
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).x;
|
|
120
|
+
}
|
|
121
|
+
if(dimensions > 2) {
|
|
122
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).x;
|
|
123
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).x;
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case 1:
|
|
127
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).y;
|
|
128
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).y;
|
|
129
|
+
if(dimensions > 1) {
|
|
130
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).y;
|
|
131
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).y;
|
|
132
|
+
}
|
|
133
|
+
if(dimensions > 2) {
|
|
134
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).y;
|
|
135
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).y;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case 2:
|
|
139
|
+
f100 = read_imagef(volume, pos + (int4)(1,0,0,0)).z;
|
|
140
|
+
f_100 = read_imagef(volume, pos - (int4)(1,0,0,0)).z;
|
|
141
|
+
if(dimensions > 1) {
|
|
142
|
+
f010 = read_imagef(volume, pos + (int4)(0,1,0,0)).z;
|
|
143
|
+
f0_10 = read_imagef(volume, pos - (int4)(0,1,0,0)).z;
|
|
144
|
+
}
|
|
145
|
+
if(dimensions > 2) {
|
|
146
|
+
f001 = read_imagef(volume, pos + (int4)(0,0,1,0)).z;
|
|
147
|
+
f00_1 = read_imagef(volume, pos - (int4)(0,0,1,0)).z;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Normalization
|
|
153
|
+
f100 /= length(read_imagef(volume, sampler, pos + (int4)(1,0,0,0)).xyz);
|
|
154
|
+
f_100 /= length(read_imagef(volume, sampler, pos - (int4)(1,0,0,0)).xyz);
|
|
155
|
+
f010 /= length(read_imagef(volume, sampler, pos + (int4)(0,1,0,0)).xyz);
|
|
156
|
+
f0_10 /= length(read_imagef(volume, sampler, pos - (int4)(0,1,0,0)).xyz);
|
|
157
|
+
f001 /= length(read_imagef(volume, sampler, pos + (int4)(0,0,1,0)).xyz);
|
|
158
|
+
f00_1 /= length(read_imagef(volume, sampler, pos - (int4)(0,0,1,0)).xyz);
|
|
159
|
+
|
|
160
|
+
float3 gradient = {
|
|
161
|
+
(f100 - f_100)/(2.0f),
|
|
162
|
+
(f010 - f0_10)/(2.0f),
|
|
163
|
+
(f001 - f00_1)/(2.0f)
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// Keep original length
|
|
168
|
+
/*
|
|
169
|
+
float gradientLength = length(gradient);
|
|
170
|
+
gradient /= spacing;
|
|
171
|
+
gradient = gradientLength*normalize(gradient);
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
return gradient;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
__kernel void toFloat(
|
|
179
|
+
__read_only image3d_t volume,
|
|
180
|
+
#ifdef fast_3d_image_writes
|
|
181
|
+
__write_only image3d_t processedVolume,
|
|
182
|
+
#else
|
|
183
|
+
__global float* processedVolume,
|
|
184
|
+
#endif
|
|
185
|
+
__private float minimum,
|
|
186
|
+
__private float maximum
|
|
187
|
+
) {
|
|
188
|
+
int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
189
|
+
|
|
190
|
+
float v = readImageToFloat(volume, pos).x;
|
|
191
|
+
|
|
192
|
+
v = v > maximum ? maximum : v;
|
|
193
|
+
v = v < minimum ? minimum : v;
|
|
194
|
+
|
|
195
|
+
// Convert to floating point representation 0 to 1
|
|
196
|
+
float value = (v - minimum) / (maximum - minimum);
|
|
197
|
+
|
|
198
|
+
// Store value
|
|
199
|
+
#ifdef fast_3d_image_writes
|
|
200
|
+
write_imagef(processedVolume, pos, value);
|
|
201
|
+
#else
|
|
202
|
+
processedVolume[LPOS(pos)] = value;
|
|
203
|
+
#endif
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
__kernel void createVectorField(
|
|
207
|
+
__read_only image3d_t volume,
|
|
208
|
+
#ifdef fast_3d_image_writes
|
|
209
|
+
__write_only image3d_t vectorField,
|
|
210
|
+
#else
|
|
211
|
+
__global VECTOR_FIELD_TYPE* vectorField,
|
|
212
|
+
#endif
|
|
213
|
+
__private float Fmax,
|
|
214
|
+
__private float vsign,
|
|
215
|
+
__private float spacing_x,
|
|
216
|
+
__private float spacing_y,
|
|
217
|
+
__private float spacing_z
|
|
218
|
+
) {
|
|
219
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
220
|
+
|
|
221
|
+
// Gradient of volume
|
|
222
|
+
float4 F;
|
|
223
|
+
F.xyz = vsign*gradient(volume, pos, 0, 3, (float3)(spacing_x, spacing_y, spacing_z)); // The sign here is important
|
|
224
|
+
F.w = 0.0f;
|
|
225
|
+
|
|
226
|
+
// Fmax normalization
|
|
227
|
+
const float l = length(F);
|
|
228
|
+
F = l < Fmax ? F/(Fmax) : F / (l);
|
|
229
|
+
F.w = 1.0f;
|
|
230
|
+
|
|
231
|
+
// Store vector field
|
|
232
|
+
#ifdef fast_3d_image_writes
|
|
233
|
+
write_imagef(vectorField, pos, F);
|
|
234
|
+
#else
|
|
235
|
+
vstore3(FLOAT_TO_SNORM16_3(F.xyz), LPOS(pos), vectorField);
|
|
236
|
+
#endif
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Forward declaration of eigen_decomp function
|
|
240
|
+
void eigen_decomposition(float M[3][3], float V[3][3], float e[3]);
|
|
241
|
+
|
|
242
|
+
__constant float cosValues[32] = {1.0f, 0.540302f, -0.416147f, -0.989992f, -0.653644f, 0.283662f, 0.96017f, 0.753902f, -0.1455f, -0.91113f, -0.839072f, 0.0044257f, 0.843854f, 0.907447f, 0.136737f, -0.759688f, -0.957659f, -0.275163f, 0.660317f, 0.988705f, 0.408082f, -0.547729f, -0.999961f, -0.532833f, 0.424179f, 0.991203f, 0.646919f, -0.292139f, -0.962606f, -0.748058f, 0.154251f, 0.914742f};
|
|
243
|
+
__constant float sinValues[32] = {0.0f, 0.841471f, 0.909297f, 0.14112f, -0.756802f, -0.958924f, -0.279415f, 0.656987f, 0.989358f, 0.412118f, -0.544021f, -0.99999f, -0.536573f, 0.420167f, 0.990607f, 0.650288f, -0.287903f, -0.961397f, -0.750987f, 0.149877f, 0.912945f, 0.836656f, -0.00885131f, -0.84622f, -0.905578f, -0.132352f, 0.762558f, 0.956376f, 0.270906f, -0.663634f, -0.988032f, -0.404038f};
|
|
244
|
+
|
|
245
|
+
__kernel void circleFittingTDF(
|
|
246
|
+
__read_only image3d_t vectorField,
|
|
247
|
+
__global TDF_TYPE * T,
|
|
248
|
+
__private float rMin,
|
|
249
|
+
__private float rMax,
|
|
250
|
+
__private float rStep,
|
|
251
|
+
__global float* Radius,
|
|
252
|
+
__private float spacing_x,
|
|
253
|
+
__private float spacing_y,
|
|
254
|
+
__private float spacing_z
|
|
255
|
+
) {
|
|
256
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
257
|
+
const float3 spacing = {spacing_x, spacing_y, spacing_z};
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
// Find Hessian Matrix
|
|
261
|
+
float3 Fx, Fy, Fz;
|
|
262
|
+
if(rMax < 4) {
|
|
263
|
+
Fx = gradient(vectorField, pos, 0, 1, spacing);
|
|
264
|
+
Fy = gradient(vectorField, pos, 1, 2, spacing);
|
|
265
|
+
Fz = gradient(vectorField, pos, 2, 3, spacing);
|
|
266
|
+
} else {
|
|
267
|
+
Fx = gradientNormalized(vectorField, pos, 0, 1, spacing);
|
|
268
|
+
Fy = gradientNormalized(vectorField, pos, 1, 2, spacing);
|
|
269
|
+
Fz = gradientNormalized(vectorField, pos, 2, 3, spacing);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
float Hessian[3][3] = {
|
|
274
|
+
{Fx.x, Fy.x, Fz.x},
|
|
275
|
+
{Fy.x, Fy.y, Fz.y},
|
|
276
|
+
{Fz.x, Fz.y, Fz.z}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// Eigen decomposition
|
|
280
|
+
float eigenValues[3];
|
|
281
|
+
float eigenVectors[3][3];
|
|
282
|
+
eigen_decomposition(Hessian, eigenVectors, eigenValues);
|
|
283
|
+
//const float3 lambda = {eigenValues[0], eigenValues[1], eigenValues[2]};
|
|
284
|
+
//const float3 e1 = {eigenVectors[0][0], eigenVectors[1][0], eigenVectors[2][0]};
|
|
285
|
+
const float3 e2 = {eigenVectors[0][1], eigenVectors[1][1], eigenVectors[2][1]};
|
|
286
|
+
const float3 e3 = {eigenVectors[0][2], eigenVectors[1][2], eigenVectors[2][2]};
|
|
287
|
+
|
|
288
|
+
// Circle Fitting
|
|
289
|
+
float maxSum = 0.0f;
|
|
290
|
+
float maxRadius = 0.0f;
|
|
291
|
+
const float4 floatPos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
292
|
+
for(float radius = rMin; radius <= rMax; radius += rStep) {
|
|
293
|
+
float radiusSum = 0.0f;
|
|
294
|
+
char samples = 32;
|
|
295
|
+
char stride = 1;
|
|
296
|
+
|
|
297
|
+
for(char j = 0; j < samples; ++j) {
|
|
298
|
+
float3 V_alpha = cosValues[j*stride]*e3 + sinValues[j*stride]*e2;
|
|
299
|
+
float4 position = floatPos + radius*V_alpha.xyzz;
|
|
300
|
+
float3 V = -read_imagef(vectorField, interpolationSampler, position).xyz;
|
|
301
|
+
radiusSum += dot(V, V_alpha);
|
|
302
|
+
}
|
|
303
|
+
radiusSum /= samples;
|
|
304
|
+
if(radiusSum > maxSum) {
|
|
305
|
+
maxSum = radiusSum;
|
|
306
|
+
maxRadius = radius;
|
|
307
|
+
} else {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// Store result
|
|
313
|
+
T[LPOS(pos)] = FLOAT_TO_UNORM16(maxSum);
|
|
314
|
+
Radius[LPOS(pos)] = maxRadius;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
__kernel void nonCircularTDF(
|
|
318
|
+
__read_only image3d_t vectorField,
|
|
319
|
+
__global TDF_TYPE * T,
|
|
320
|
+
__private float rMin,
|
|
321
|
+
__private float rMax,
|
|
322
|
+
__private float rStep,
|
|
323
|
+
__private const int arms,
|
|
324
|
+
__private const float minAverageMag,
|
|
325
|
+
__global float * R,
|
|
326
|
+
__private float spacing_x,
|
|
327
|
+
__private float spacing_y,
|
|
328
|
+
__private float spacing_z
|
|
329
|
+
) {
|
|
330
|
+
const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};
|
|
331
|
+
const float3 spacing = {spacing_x, spacing_y, spacing_z};
|
|
332
|
+
char invalid = 0;
|
|
333
|
+
|
|
334
|
+
// Find Hessian Matrix
|
|
335
|
+
const float3 Fx = gradientNormalized(vectorField, pos, 0, 1, spacing);
|
|
336
|
+
const float3 Fy = gradientNormalized(vectorField, pos, 1, 2, spacing);
|
|
337
|
+
const float3 Fz = gradientNormalized(vectorField, pos, 2, 3, spacing);
|
|
338
|
+
|
|
339
|
+
float Hessian[3][3] = {
|
|
340
|
+
{Fx.x, Fy.x, Fz.x},
|
|
341
|
+
{Fy.x, Fy.y, Fz.y},
|
|
342
|
+
{Fz.x, Fz.y, Fz.z}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// Eigen decomposition
|
|
346
|
+
float eigenValues[3];
|
|
347
|
+
float eigenVectors[3][3];
|
|
348
|
+
eigen_decomposition(Hessian, eigenVectors, eigenValues);
|
|
349
|
+
const float3 e1 = {eigenVectors[0][0], eigenVectors[1][0], eigenVectors[2][0]};
|
|
350
|
+
const float3 e2 = {eigenVectors[0][1], eigenVectors[1][1], eigenVectors[2][1]};
|
|
351
|
+
const float3 e3 = {eigenVectors[0][2], eigenVectors[1][2], eigenVectors[2][2]};
|
|
352
|
+
|
|
353
|
+
float currentVoxelMagnitude = length(read_imagef(vectorField, sampler, pos).xyz);
|
|
354
|
+
|
|
355
|
+
float maxRadius[12]; // 12 is maximum nr of arms atm.
|
|
356
|
+
float sum = 0.0f;
|
|
357
|
+
//float minAverageMag = 0.01f; // 0.01
|
|
358
|
+
float largestRadius = 0;
|
|
359
|
+
for(char j = 0; j < arms; ++j) {
|
|
360
|
+
maxRadius[j] = 999;
|
|
361
|
+
float alpha = 2 * M_PI_F * j / arms;
|
|
362
|
+
float4 V_alpha = cos(alpha)*e3.xyzz + sin(alpha)*e2.xyzz;
|
|
363
|
+
float prevMagnitude2 = currentVoxelMagnitude;
|
|
364
|
+
float4 position = convert_float4(pos) + rMin*V_alpha;
|
|
365
|
+
float prevMagnitude = length(read_imagef(vectorField, interpolationSampler, position).xyz);
|
|
366
|
+
char up = prevMagnitude2 > prevMagnitude ? 0 : 1;
|
|
367
|
+
|
|
368
|
+
// Perform the actual line search
|
|
369
|
+
for(float radius = rMin+rStep; radius <= rMax; radius += rStep) {
|
|
370
|
+
position = convert_float4(pos) + radius*V_alpha;
|
|
371
|
+
float4 vec = read_imagef(vectorField, interpolationSampler, position);
|
|
372
|
+
vec.w = 0.0f;
|
|
373
|
+
float magnitude = length(vec.xyz);
|
|
374
|
+
|
|
375
|
+
// Is a border point found?
|
|
376
|
+
if(up == 1 && magnitude < prevMagnitude && (prevMagnitude+magnitude)/2.0f - currentVoxelMagnitude > minAverageMag) { // Dot produt here is test
|
|
377
|
+
maxRadius[j] = radius;
|
|
378
|
+
if(radius > largestRadius)
|
|
379
|
+
largestRadius = radius;
|
|
380
|
+
if(dot(normalize(vec.xyz), -normalize(V_alpha.xyz)) < 0.0f) {
|
|
381
|
+
invalid = 1;
|
|
382
|
+
sum = 0.0f;
|
|
383
|
+
//break;
|
|
384
|
+
}
|
|
385
|
+
sum += 1.0f-fabs(dot(normalize(vec.xyz), e1));
|
|
386
|
+
break;
|
|
387
|
+
} // End found border point
|
|
388
|
+
|
|
389
|
+
if(magnitude > prevMagnitude) {
|
|
390
|
+
up = 1;
|
|
391
|
+
}
|
|
392
|
+
prevMagnitude = magnitude;
|
|
393
|
+
} // End for each radius
|
|
394
|
+
|
|
395
|
+
if(maxRadius[j] == 999 || invalid == 1) {
|
|
396
|
+
invalid = 1;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
} // End for arms
|
|
400
|
+
|
|
401
|
+
if(invalid != 1) {
|
|
402
|
+
float avgSymmetry = 0.0f;
|
|
403
|
+
for(char j = 0; j < arms/2; ++j) {
|
|
404
|
+
avgSymmetry += min(maxRadius[j], maxRadius[arms/2 + j]) /
|
|
405
|
+
max(maxRadius[j], maxRadius[arms/2+j]);
|
|
406
|
+
}
|
|
407
|
+
avgSymmetry /= arms/2;
|
|
408
|
+
R[LPOS(pos)] = largestRadius;
|
|
409
|
+
T[LPOS(pos)] = FLOAT_TO_UNORM16(min(1.0f, (sum / (arms))*avgSymmetry+0.2f));
|
|
410
|
+
} else {
|
|
411
|
+
R[LPOS(pos)] = 0;
|
|
412
|
+
T[LPOS(pos)] = 0;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
int dsyevj3(float A[3][3], float Q[3][3], float w[3])
|
|
416
|
+
// ----------------------------------------------------------------------------
|
|
417
|
+
// Calculates the eigenvalues and normalized eigenvectors of a symmetric 3x3
|
|
418
|
+
// matrix A using the Jacobi algorithm.
|
|
419
|
+
// The upper triangular part of A is destroyed during the calculation,
|
|
420
|
+
// the diagonal elements are read but not destroyed, and the lower
|
|
421
|
+
// triangular elements are not referenced at all.
|
|
422
|
+
// ----------------------------------------------------------------------------
|
|
423
|
+
// Parameters:
|
|
424
|
+
// A: The symmetric input matrix
|
|
425
|
+
// Q: Storage buffer for eigenvectors
|
|
426
|
+
// w: Storage buffer for eigenvalues
|
|
427
|
+
// ----------------------------------------------------------------------------
|
|
428
|
+
// Return value:
|
|
429
|
+
// 0: Success
|
|
430
|
+
// -1: Error (no convergence)
|
|
431
|
+
// ----------------------------------------------------------------------------
|
|
432
|
+
{
|
|
433
|
+
const int n = 3;
|
|
434
|
+
float sd, so; // Sums of diagonal resp. off-diagonal elements
|
|
435
|
+
float s, c, t; // sin(phi), cos(phi), tan(phi) and temporary storage
|
|
436
|
+
float g, h, z, theta; // More temporary storage
|
|
437
|
+
float thresh;
|
|
438
|
+
|
|
439
|
+
// Initialize Q to the identitity matrix
|
|
440
|
+
for (int i=0; i < n; i++)
|
|
441
|
+
{
|
|
442
|
+
Q[i][i] = 1.0;
|
|
443
|
+
for (int j=0; j < i; j++)
|
|
444
|
+
Q[i][j] = Q[j][i] = 0.0;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Initialize w to diag(A)
|
|
448
|
+
for (int i=0; i < n; i++)
|
|
449
|
+
w[i] = A[i][i];
|
|
450
|
+
|
|
451
|
+
// Calculate SQR(tr(A))
|
|
452
|
+
sd = 0.0;
|
|
453
|
+
for (int i=0; i < n; i++)
|
|
454
|
+
sd += fabs(w[i]);
|
|
455
|
+
sd = sd*sd;
|
|
456
|
+
|
|
457
|
+
// Main iteration loop
|
|
458
|
+
for (int nIter=0; nIter < 50; nIter++)
|
|
459
|
+
{
|
|
460
|
+
// Test for convergence
|
|
461
|
+
so = 0.0;
|
|
462
|
+
for (int p=0; p < n; p++)
|
|
463
|
+
for (int q=p+1; q < n; q++)
|
|
464
|
+
so += fabs(A[p][q]);
|
|
465
|
+
if (so == 0.0)
|
|
466
|
+
return 0;
|
|
467
|
+
|
|
468
|
+
if (nIter < 4) {
|
|
469
|
+
thresh = 0.2 * so / (n*n);
|
|
470
|
+
} else {
|
|
471
|
+
thresh = 0.0;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// Do sweep
|
|
475
|
+
for (int p=0; p < n; p++)
|
|
476
|
+
for (int q=p+1; q < n; q++)
|
|
477
|
+
{
|
|
478
|
+
g = 100.0 * fabs(A[p][q]);
|
|
479
|
+
if (nIter > 4 && fabs(w[p]) + g == fabs(w[p])
|
|
480
|
+
&& fabs(w[q]) + g == fabs(w[q]))
|
|
481
|
+
{
|
|
482
|
+
A[p][q] = 0.0;
|
|
483
|
+
}
|
|
484
|
+
else if (fabs(A[p][q]) > thresh)
|
|
485
|
+
{
|
|
486
|
+
// Calculate Jacobi transformation
|
|
487
|
+
h = w[q] - w[p];
|
|
488
|
+
if (fabs(h) + g == fabs(h))
|
|
489
|
+
{
|
|
490
|
+
t = A[p][q] / h;
|
|
491
|
+
}
|
|
492
|
+
else
|
|
493
|
+
{
|
|
494
|
+
theta = 0.5 * h / A[p][q];
|
|
495
|
+
if (theta < 0.0)
|
|
496
|
+
t = -1.0 / (sqrt(1.0 + theta*theta) - theta);
|
|
497
|
+
else
|
|
498
|
+
t = 1.0 / (sqrt(1.0 + theta*theta) + theta);
|
|
499
|
+
}
|
|
500
|
+
c = 1.0/sqrt(1.0 + t*t);
|
|
501
|
+
s = t * c;
|
|
502
|
+
z = t * A[p][q];
|
|
503
|
+
|
|
504
|
+
// Apply Jacobi transformation
|
|
505
|
+
A[p][q] = 0.0;
|
|
506
|
+
w[p] -= z;
|
|
507
|
+
w[q] += z;
|
|
508
|
+
for (int r=0; r < p; r++)
|
|
509
|
+
{
|
|
510
|
+
t = A[r][p];
|
|
511
|
+
A[r][p] = c*t - s*A[r][q];
|
|
512
|
+
A[r][q] = s*t + c*A[r][q];
|
|
513
|
+
}
|
|
514
|
+
for (int r=p+1; r < q; r++)
|
|
515
|
+
{
|
|
516
|
+
t = A[p][r];
|
|
517
|
+
A[p][r] = c*t - s*A[r][q];
|
|
518
|
+
A[r][q] = s*t + c*A[r][q];
|
|
519
|
+
}
|
|
520
|
+
for (int r=q+1; r < n; r++)
|
|
521
|
+
{
|
|
522
|
+
t = A[p][r];
|
|
523
|
+
A[p][r] = c*t - s*A[q][r];
|
|
524
|
+
A[q][r] = s*t + c*A[q][r];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Update eigenvectors
|
|
528
|
+
for (int r=0; r < n; r++)
|
|
529
|
+
{
|
|
530
|
+
t = Q[r][p];
|
|
531
|
+
Q[r][p] = c*t - s*Q[r][q];
|
|
532
|
+
Q[r][q] = s*t + c*Q[r][q];
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
return -1;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
void eigen_decomposition(float A[3][3], float V[3][3], float d[3]) {
|
|
544
|
+
dsyevj3(A, V, d);
|
|
545
|
+
|
|
546
|
+
// Sort eigenvalues and corresponding vectors.
|
|
547
|
+
for (char i = 0; i < 3; ++i) {
|
|
548
|
+
char k = i;
|
|
549
|
+
float p = d[i];
|
|
550
|
+
for (char j = i+1; j < 3; ++j) {
|
|
551
|
+
if (fabs(d[j]) < fabs(p)) {
|
|
552
|
+
k = j;
|
|
553
|
+
p = d[j];
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (k != i) {
|
|
557
|
+
d[k] = d[i];
|
|
558
|
+
d[i] = p;
|
|
559
|
+
for (char j = 0; j < 3; ++j) {
|
|
560
|
+
p = V[j][i];
|
|
561
|
+
V[j][i] = V[j][k];
|
|
562
|
+
V[j][k] = p;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
|
|
2
|
+
|
|
3
|
+
inline float2 complexDivision(float2 a, float2 b){
|
|
4
|
+
return (float2)(
|
|
5
|
+
(a.x*b.x + a.y*b.y)/(b.x*b.x + b.y*b.y),
|
|
6
|
+
(a.y*b.x - a.x*b.y)/(b.x*b.x + b.y*b.y)
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
__kernel void envelopeAndLogCompress(
|
|
11
|
+
__read_only image2d_t input,
|
|
12
|
+
__write_only image2d_t output
|
|
13
|
+
) {
|
|
14
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
15
|
+
|
|
16
|
+
float2 iq = read_imagef(input, sampler, pos).xy;
|
|
17
|
+
write_imagef(output, pos, 20.0f * log10(length(iq))); // Length is abs for complex
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
__kernel void normalizeEnvelope(
|
|
21
|
+
__read_only image2d_t input,
|
|
22
|
+
__write_only image2d_t output,
|
|
23
|
+
__private float maxdB
|
|
24
|
+
) {
|
|
25
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
26
|
+
|
|
27
|
+
write_imagef(output, pos, read_imagef(input, sampler, pos).x - maxdB);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
__kernel void normalizeEnvelopeToGrayscale(
|
|
31
|
+
__read_only image2d_t input,
|
|
32
|
+
__write_only image2d_t output,
|
|
33
|
+
__private float maxdB,
|
|
34
|
+
__private float gain,
|
|
35
|
+
__private float dynamicRange
|
|
36
|
+
) {
|
|
37
|
+
const int2 pos = {get_global_id(0), get_global_id(1)};
|
|
38
|
+
|
|
39
|
+
float dBPixel = read_imagef(input, sampler, pos).x - maxdB;
|
|
40
|
+
float img_sc_reject = dBPixel + gain;
|
|
41
|
+
img_sc_reject = (img_sc_reject < -dynamicRange) ? -dynamicRange : img_sc_reject; //Reject everything below dynamic range
|
|
42
|
+
img_sc_reject = (img_sc_reject > 0) ? 0 : img_sc_reject; // Everything above 0 dB should be saturated
|
|
43
|
+
uchar img_gray_scale = round(255*(img_sc_reject+dynamicRange)/dynamicRange);
|
|
44
|
+
write_imageui(output, pos, img_gray_scale);
|
|
45
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const sampler_t sampler = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_MIRRORED_REPEAT | CLK_FILTER_LINEAR;
|
|
2
|
+
|
|
3
|
+
void cart2pol(float x, float y, float *r, float *th) {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
__kernel void scanConvert(
|
|
8
|
+
__read_only image2d_t input,
|
|
9
|
+
__write_only image2d_t output,
|
|
10
|
+
__private float gain,
|
|
11
|
+
__private float dynamicRange,
|
|
12
|
+
__private float newXSpacing,
|
|
13
|
+
__private float newYSpacing,
|
|
14
|
+
__private float startX,
|
|
15
|
+
__private float startY,
|
|
16
|
+
__private float startDepth,
|
|
17
|
+
__private float startAzimuth,
|
|
18
|
+
__private float depthSpacing,
|
|
19
|
+
__private float azimuthSpacing,
|
|
20
|
+
__private int isPolar
|
|
21
|
+
) {
|
|
22
|
+
int2 pos = {get_global_id(0), get_global_id(1)};
|
|
23
|
+
float x = pos.x*newXSpacing + startX;
|
|
24
|
+
float y = pos.y*newYSpacing + startY;
|
|
25
|
+
// Cart 2 polar
|
|
26
|
+
float r = isPolar == 1 ? sqrt(x*x + y*y) : y;
|
|
27
|
+
float th = isPolar == 1 ? atan2(x, y) : x;
|
|
28
|
+
|
|
29
|
+
// Normalize
|
|
30
|
+
r = ((r - startDepth)/depthSpacing)/get_image_height(input);
|
|
31
|
+
th = ((th - startAzimuth)/azimuthSpacing)/get_image_width(input);
|
|
32
|
+
|
|
33
|
+
if(r < 0.0f || r > 1.0f || th < 0.0f || th > 1.0f) {
|
|
34
|
+
// Out of bounds
|
|
35
|
+
write_imageui(output, pos, 0);
|
|
36
|
+
} else {
|
|
37
|
+
float dBPixel = read_imagef(input, sampler, (float2)(th, r)).x;
|
|
38
|
+
float img_sc_reject = dBPixel + gain;
|
|
39
|
+
img_sc_reject = (img_sc_reject < -dynamicRange) ? -dynamicRange : img_sc_reject; //Reject everything below dynamic range
|
|
40
|
+
img_sc_reject = (img_sc_reject > 0) ? 0 : img_sc_reject; // Everything above 0 dB should be saturated
|
|
41
|
+
uchar img_gray_scale = round(255*(img_sc_reject+dynamicRange)/dynamicRange);
|
|
42
|
+
write_imageui(output, pos, img_gray_scale);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
__kernel void scanConvertGrayscale(
|
|
47
|
+
__read_only image2d_t input,
|
|
48
|
+
__write_only image2d_t output,
|
|
49
|
+
__private float newXSpacing,
|
|
50
|
+
__private float newYSpacing,
|
|
51
|
+
__private float startX,
|
|
52
|
+
__private float startY,
|
|
53
|
+
__private float startDepth,
|
|
54
|
+
__private float startAzimuth,
|
|
55
|
+
__private float depthSpacing,
|
|
56
|
+
__private float azimuthSpacing,
|
|
57
|
+
__private int isPolar
|
|
58
|
+
) {
|
|
59
|
+
int2 pos = {get_global_id(0), get_global_id(1)};
|
|
60
|
+
float x = pos.x*newXSpacing + startX;
|
|
61
|
+
float y = pos.y*newYSpacing + startY;
|
|
62
|
+
// Cart 2 polar
|
|
63
|
+
float r = isPolar == 1 ? sqrt(x*x + y*y) : y;
|
|
64
|
+
float th = isPolar == 1 ? atan2(x, y) : x;
|
|
65
|
+
|
|
66
|
+
// Normalize
|
|
67
|
+
r = ((r - startDepth)/depthSpacing)/get_image_height(input);
|
|
68
|
+
th = ((th - startAzimuth)/azimuthSpacing)/get_image_width(input);
|
|
69
|
+
|
|
70
|
+
if(r < 0.0f || r > 1.0f || th < 0.0f || th > 1.0f) {
|
|
71
|
+
// Out of bounds
|
|
72
|
+
write_imageui(output, pos, 0);
|
|
73
|
+
} else {
|
|
74
|
+
write_imageui(output, pos, read_imageui(input, sampler, (float2)(th, r)));
|
|
75
|
+
}
|
|
76
|
+
}
|