summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2015-02-24 12:15:25 +0100
committerWillem Jan Palenstijn <wjp@usecode.org>2015-02-24 12:15:25 +0100
commitf619aba4543de6b9a4fe6fb63b6f1840ef509846 (patch)
tree1229bc07f27ef593a07fd56aebed177380e68cb9
parentb16c26d1fd7a50fda648dd63076e011d122543b8 (diff)
parentfbb746d3f32105f7fc57d5b34203d291461d9b43 (diff)
downloadastra-f619aba4543de6b9a4fe6fb63b6f1840ef509846.tar.gz
astra-f619aba4543de6b9a4fe6fb63b6f1840ef509846.tar.bz2
astra-f619aba4543de6b9a4fe6fb63b6f1840ef509846.tar.xz
astra-f619aba4543de6b9a4fe6fb63b6f1840ef509846.zip
Merge pull request #13 from astra-toolbox/matlab-data3d-logical
Added support for logical matrices in mex_data3d
-rw-r--r--matlab/mex/astra_mex_data3d_c.cpp2
-rw-r--r--matlab/mex/mexCopyDataHelpFunctions.cpp42
-rw-r--r--matlab/mex/mexDataManagerHelpFunctions.cpp12
-rw-r--r--matlab/mex/mexDataManagerHelpFunctions.h10
-rw-r--r--matlab/mex/mexHelpFunctions.h10
5 files changed, 53 insertions, 23 deletions
diff --git a/matlab/mex/astra_mex_data3d_c.cpp b/matlab/mex/astra_mex_data3d_c.cpp
index db81519..35a7512 100644
--- a/matlab/mex/astra_mex_data3d_c.cpp
+++ b/matlab/mex/astra_mex_data3d_c.cpp
@@ -79,7 +79,7 @@ void astra_mex_data3d_create(int& nlhs, mxArray* plhs[], int& nrhs, const mxArra
}
if (data && !checkDataType(data)) {
- mexErrMsgTxt("Data must be single or double.");
+ mexErrMsgTxt("Data must be single, double or logical.");
return;
}
diff --git a/matlab/mex/mexCopyDataHelpFunctions.cpp b/matlab/mex/mexCopyDataHelpFunctions.cpp
index bbcad30..6dfd4a6 100644
--- a/matlab/mex/mexCopyDataHelpFunctions.cpp
+++ b/matlab/mex/mexCopyDataHelpFunctions.cpp
@@ -1,13 +1,13 @@
/*
-----------------------------------------------------------------------
-Copyright 2013 iMinds-Vision Lab, University of Antwerp
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
-Contact: astra@ua.ac.be
-Website: http://astra.ua.ac.be
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+This file is part of the ASTRA Toolbox.
-This file is part of the
-All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,7 +40,6 @@ $Id$
#if defined(__SSE2__)
# include <emmintrin.h>
-
# define STORE_32F_64F_CORE8(in, out, count, base) \
{\
const __m128 inV0 = *((const __m128 *) &in[count + 0 + base]);\
@@ -108,6 +107,17 @@ $Id$
out[count + 7 + base] = in[count + 7 + base];\
}
#endif
+#define STORE_8F_32F_CORE8(in, out, count, base) \
+ {\
+ out[count + 0 + base] = (float)in[count + 0 + base];\
+ out[count + 1 + base] = (float)in[count + 1 + base];\
+ out[count + 2 + base] = (float)in[count + 2 + base];\
+ out[count + 3 + base] = (float)in[count + 3 + base];\
+ out[count + 4 + base] = (float)in[count + 4 + base];\
+ out[count + 5 + base] = (float)in[count + 5 + base];\
+ out[count + 6 + base] = (float)in[count + 6 + base];\
+ out[count + 7 + base] = (float)in[count + 7 + base];\
+ }
const char * warnDataTypeNotSupported = "Data type not supported: nothing was copied";
@@ -118,6 +128,7 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou
const long long block = 32;
const long long totRoundedPixels = ROUND_DOWN(tot_size, block);
+ // Array of doubles
if (mxIsDouble(inArray)) {
const double * const pdMatlabData = mxGetPr(inArray);
@@ -133,6 +144,8 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou
out[count] = pdMatlabData[count];
}
}
+
+ // Array of floats
else if (mxIsSingle(inArray)) {
const float * const pfMatlabData = (const float *)mxGetData(inArray);
@@ -148,6 +161,23 @@ _copyMexToCFloat32Array(const mxArray * const inArray, astra::float32 * const ou
out[count] = pfMatlabData[count];
}
}
+
+ // Array of logicals
+ else if (mxIsLogical(inArray)) {
+ const mxLogical * const pfMatlabData = (const mxLogical *)mxGetLogicals(inArray);
+
+#pragma omp for nowait
+ for (long long count = 0; count < totRoundedPixels; count += block) {
+ STORE_8F_32F_CORE8(pfMatlabData, out, count, 0);
+ STORE_8F_32F_CORE8(pfMatlabData, out, count, 8);
+ STORE_8F_32F_CORE8(pfMatlabData, out, count, 16);
+ STORE_8F_32F_CORE8(pfMatlabData, out, count, 24);
+ }
+#pragma omp for nowait
+ for (long long count = totRoundedPixels; count < tot_size; count++) {
+ out[count] = pfMatlabData[count];
+ }
+ }
else {
#pragma omp single nowait
mexWarnMsgIdAndTxt("ASTRA_MEX:wrong_datatype", warnDataTypeNotSupported);
diff --git a/matlab/mex/mexDataManagerHelpFunctions.cpp b/matlab/mex/mexDataManagerHelpFunctions.cpp
index 5e6020b..f9d971c 100644
--- a/matlab/mex/mexDataManagerHelpFunctions.cpp
+++ b/matlab/mex/mexDataManagerHelpFunctions.cpp
@@ -1,13 +1,13 @@
/*
-----------------------------------------------------------------------
-Copyright 2013 iMinds-Vision Lab, University of Antwerp
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
-Contact: astra@ua.ac.be
-Website: http://astra.ua.ac.be
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+This file is part of the ASTRA Toolbox.
-This file is part of the
-All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -105,7 +105,7 @@ checkID(const astra::int32 & id, astra::CFloat32Data3DMemory *& pDataObj)
bool
checkDataType(const mxArray * const in)
{
- return (mex_is_scalar(in) || mxIsDouble(in) || mxIsSingle(in));
+ return (mex_is_scalar(in) || mxIsDouble(in) || mxIsSingle(in) || mxIsLogical(in));
}
//-----------------------------------------------------------------------------------------
diff --git a/matlab/mex/mexDataManagerHelpFunctions.h b/matlab/mex/mexDataManagerHelpFunctions.h
index 36b74d8..0614e05 100644
--- a/matlab/mex/mexDataManagerHelpFunctions.h
+++ b/matlab/mex/mexDataManagerHelpFunctions.h
@@ -1,13 +1,13 @@
/*
-----------------------------------------------------------------------
-Copyright 2013 iMinds-Vision Lab, University of Antwerp
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
-Contact: astra@ua.ac.be
-Website: http://astra.ua.ac.be
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+This file is part of the ASTRA Toolbox.
-This file is part of the
-All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/matlab/mex/mexHelpFunctions.h b/matlab/mex/mexHelpFunctions.h
index 425b4ef..84372ba 100644
--- a/matlab/mex/mexHelpFunctions.h
+++ b/matlab/mex/mexHelpFunctions.h
@@ -1,13 +1,13 @@
/*
-----------------------------------------------------------------------
-Copyright 2012 iMinds-Vision Lab, University of Antwerp
+Copyright: 2010-2015, iMinds-Vision Lab, University of Antwerp
+ 2014-2015, CWI, Amsterdam
-Contact: astra@ua.ac.be
-Website: http://astra.ua.ac.be
+Contact: astra@uantwerpen.be
+Website: http://sf.net/projects/astra-toolbox
+This file is part of the ASTRA Toolbox.
-This file is part of the
-All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA Toolbox").
The ASTRA Toolbox is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by