summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2017-08-04 16:14:24 +0100
committerEdoardo Pasca <edo.paskino@gmail.com>2017-10-11 15:38:08 +0100
commit28e07bd6fb75d36ac0ee230b894adad9bc6760d4 (patch)
treed43e198c7bb82fa50367822a0980bf47ddb54a39
parent87fdeb59a0fd3456eabe3ebf045f989f1d833cab (diff)
downloadregularization-28e07bd6fb75d36ac0ee230b894adad9bc6760d4.tar.gz
regularization-28e07bd6fb75d36ac0ee230b894adad9bc6760d4.tar.bz2
regularization-28e07bd6fb75d36ac0ee230b894adad9bc6760d4.tar.xz
regularization-28e07bd6fb75d36ac0ee230b894adad9bc6760d4.zip
extern C function called by C++
adds extern "C" to the definition of the functions if the code is called from C++ rather than from C/Matlab
-rw-r--r--main_func/regularizers_CPU/FGP_TV_core.h11
-rw-r--r--main_func/regularizers_CPU/LLT_model_core.h10
-rw-r--r--main_func/regularizers_CPU/PatchBased_Regul_core.h40
-rw-r--r--main_func/regularizers_CPU/SplitBregman_TV_core.h12
-rw-r--r--main_func/regularizers_CPU/TGV_PD_core.h35
5 files changed, 98 insertions, 10 deletions
diff --git a/main_func/regularizers_CPU/FGP_TV_core.h b/main_func/regularizers_CPU/FGP_TV_core.h
index d256c9a..7e7229a 100644
--- a/main_func/regularizers_CPU/FGP_TV_core.h
+++ b/main_func/regularizers_CPU/FGP_TV_core.h
@@ -3,7 +3,7 @@ This work is part of the Core Imaging Library developed by
Visual Analytics and Imaging System Group of the Science Technology
Facilities Council, STFC
-Copyright 2017 Daniil Kazanteev
+Copyright 2017 Daniil Kazantsev
Copyright 2017 Srikanth Nagella, Edoardo Pasca
Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-#include <matrix.h>
+//#include <matrix.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
@@ -51,7 +51,9 @@ limitations under the License.
* D. Kazantsev, 2016-17
*
*/
-
+#ifdef __cplusplus
+extern "C" {
+#endif
//float copyIm(float *A, float *B, int dimX, int dimY, int dimZ);
float Obj_func2D(float *A, float *D, float *R1, float *R2, float lambda, int dimX, int dimY);
float Grad_func2D(float *P1, float *P2, float *D, float *R1, float *R2, float lambda, int dimX, int dimY);
@@ -64,3 +66,6 @@ float Grad_func3D(float *P1, float *P2, float *P3, float *D, float *R1, float *R
float Proj_func3D(float *P1, float *P2, float *P3, int dimX, int dimY, int dimZ);
float Rupd_func3D(float *P1, float *P1_old, float *P2, float *P2_old, float *P3, float *P3_old, float *R1, float *R2, float *R3, float tkp1, float tk, int dimX, int dimY, int dimZ);
float Obj_func_CALC3D(float *A, float *D, float *funcvalA, float lambda, int dimX, int dimY, int dimZ);
+#ifdef __cplusplus
+}
+#endif
diff --git a/main_func/regularizers_CPU/LLT_model_core.h b/main_func/regularizers_CPU/LLT_model_core.h
index 560bb9c..13fce5a 100644
--- a/main_func/regularizers_CPU/LLT_model_core.h
+++ b/main_func/regularizers_CPU/LLT_model_core.h
@@ -3,7 +3,7 @@ This work is part of the Core Imaging Library developed by
Visual Analytics and Imaging System Group of the Science Technology
Facilities Council, STFC
-Copyright 2017 Daniil Kazanteev
+Copyright 2017 Daniil Kazantsev
Copyright 2017 Srikanth Nagella, Edoardo Pasca
Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-#include <matrix.h>
+//#include <matrix.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
@@ -28,6 +28,9 @@ limitations under the License.
#define EPS 0.01
/* 2D functions */
+#ifdef __cplusplus
+extern "C" {
+#endif
float der2D(float *U, float *D1, float *D2, int dimX, int dimY, int dimZ);
float div_upd2D(float *U0, float *U, float *D1, float *D2, int dimX, int dimY, int dimZ, float lambda, float tau);
@@ -38,3 +41,6 @@ float calcMap(float *U, unsigned short *Map, int dimX, int dimY, int dimZ);
float cleanMap(unsigned short *Map, int dimX, int dimY, int dimZ);
//float copyIm(float *A, float *U, int dimX, int dimY, int dimZ);
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/main_func/regularizers_CPU/PatchBased_Regul_core.h b/main_func/regularizers_CPU/PatchBased_Regul_core.h
index 5aa6415..d4a8a46 100644
--- a/main_func/regularizers_CPU/PatchBased_Regul_core.h
+++ b/main_func/regularizers_CPU/PatchBased_Regul_core.h
@@ -19,13 +19,51 @@ limitations under the License.
#define _USE_MATH_DEFINES
-#include <matrix.h>
+//#include <matrix.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
#include <stdio.h>
#include "omp.h"
+/* C-OMP implementation of patch-based (PB) regularization (2D and 3D cases).
+* This method finds self-similar patches in data and performs one fixed point iteration to mimimize the PB penalty function
+*
+* References: 1. Yang Z. & Jacob M. "Nonlocal Regularization of Inverse Problems"
+* 2. Kazantsev D. et al. "4D-CT reconstruction with unified spatial-temporal patch-based regularization"
+*
+* Input Parameters (mandatory):
+* 1. Image (2D or 3D)
+* 2. ratio of the searching window (e.g. 3 = (2*3+1) = 7 pixels window)
+* 3. ratio of the similarity window (e.g. 1 = (2*1+1) = 3 pixels window)
+* 4. h - parameter for the PB penalty function
+* 5. lambda - regularization parameter
+
+* Output:
+* 1. regularized (denoised) Image (N x N)/volume (N x N x N)
+*
+* Quick 2D denoising example in Matlab:
+Im = double(imread('lena_gray_256.tif'))/255; % loading image
+u0 = Im + .03*randn(size(Im)); u0(u0<0) = 0; % adding noise
+ImDen = PB_Regul_CPU(single(u0), 3, 1, 0.08, 0.05);
+*
+* Please see more tests in a file:
+TestTemporalSmoothing.m
+
+*
+* Matlab + C/mex compilers needed
+* to compile with OMP support: mex PB_Regul_CPU.c CFLAGS="\$CFLAGS -fopenmp -Wall" LDFLAGS="\$LDFLAGS -fopenmp"
+*
+* D. Kazantsev *
+* 02/07/2014
+* Harwell, UK
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
float pad_crop(float *A, float *Ap, int OldSizeX, int OldSizeY, int OldSizeZ, int NewSizeX, int NewSizeY, int NewSizeZ, int padXY, int switchpad_crop);
float PB_FUNC2D(float *A, float *B, int dimX, int dimY, int padXY, int SearchW, int SimilW, float h, float lambda);
float PB_FUNC3D(float *A, float *B, int dimX, int dimY, int dimZ, int padXY, int SearchW, int SimilW, float h, float lambda);
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/main_func/regularizers_CPU/SplitBregman_TV_core.h b/main_func/regularizers_CPU/SplitBregman_TV_core.h
index 78aef09..6ed3ff9 100644
--- a/main_func/regularizers_CPU/SplitBregman_TV_core.h
+++ b/main_func/regularizers_CPU/SplitBregman_TV_core.h
@@ -3,7 +3,7 @@ This work is part of the Core Imaging Library developed by
Visual Analytics and Imaging System Group of the Science Technology
Facilities Council, STFC
-Copyright 2017 Daniil Kazanteev
+Copyright 2017 Daniil Kazantsev
Copyright 2017 Srikanth Nagella, Edoardo Pasca
Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-#include <matrix.h>
+//#include <matrix.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
@@ -49,6 +49,10 @@ limitations under the License.
* D. Kazantsev, 2016*
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
//float copyIm(float *A, float *B, int dimX, int dimY, int dimZ);
float gauss_seidel2D(float *U, float *A, float *Dx, float *Dy, float *Bx, float *By, int dimX, int dimY, float lambda, float mu);
float updDxDy_shrinkAniso2D(float *U, float *Dx, float *Dy, float *Bx, float *By, int dimX, int dimY, float lambda);
@@ -59,3 +63,7 @@ float gauss_seidel3D(float *U, float *A, float *Dx, float *Dy, float *Dz, float
float updDxDyDz_shrinkAniso3D(float *U, float *Dx, float *Dy, float *Dz, float *Bx, float *By, float *Bz, int dimX, int dimY, int dimZ, float lambda);
float updDxDyDz_shrinkIso3D(float *U, float *Dx, float *Dy, float *Dz, float *Bx, float *By, float *Bz, int dimX, int dimY, int dimZ, float lambda);
float updBxByBz3D(float *U, float *Dx, float *Dy, float *Dz, float *Bx, float *By, float *Bz, int dimX, int dimY, int dimZ);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/main_func/regularizers_CPU/TGV_PD_core.h b/main_func/regularizers_CPU/TGV_PD_core.h
index cbe7ea4..d5378df 100644
--- a/main_func/regularizers_CPU/TGV_PD_core.h
+++ b/main_func/regularizers_CPU/TGV_PD_core.h
@@ -3,7 +3,7 @@ This work is part of the Core Imaging Library developed by
Visual Analytics and Imaging System Group of the Science Technology
Facilities Council, STFC
-Copyright 2017 Daniil Kazanteev
+Copyright 2017 Daniil Kazantsev
Copyright 2017 Srikanth Nagella, Edoardo Pasca
Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-#include <matrix.h>
+//#include <matrix.h>
#include <math.h>
#include <stdlib.h>
#include <memory.h>
@@ -25,6 +25,34 @@ limitations under the License.
#include "omp.h"
#include "utils.h"
+/* C-OMP implementation of Primal-Dual denoising method for
+* Total Generilized Variation (TGV)-L2 model (2D case only)
+*
+* Input Parameters:
+* 1. Noisy image/volume (2D)
+* 2. lambda - regularization parameter
+* 3. parameter to control first-order term (alpha1)
+* 4. parameter to control the second-order term (alpha0)
+* 5. Number of CP iterations
+*
+* Output:
+* Filtered/regularized image
+*
+* Example:
+* figure;
+* Im = double(imread('lena_gray_256.tif'))/255; % loading image
+* u0 = Im + .03*randn(size(Im)); % adding noise
+* tic; u = PrimalDual_TGV(single(u0), 0.02, 1.3, 1, 550); toc;
+*
+* to compile with OMP support: mex TGV_PD.c CFLAGS="\$CFLAGS -fopenmp -Wall -std=c99" LDFLAGS="\$LDFLAGS -fopenmp"
+* References:
+* K. Bredies "Total Generalized Variation"
+*
+* 28.11.16/Harwell
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
/* 2D functions */
float DualP_2D(float *U, float *V1, float *V2, float *P1, float *P2, int dimX, int dimY, int dimZ, float sigma);
float ProjP_2D(float *P1, float *P2, int dimX, int dimY, int dimZ, float alpha1);
@@ -34,3 +62,6 @@ float DivProjP_2D(float *U, float *A, float *P1, float *P2, int dimX, int dimY,
float UpdV_2D(float *V1, float *V2, float *P1, float *P2, float *Q1, float *Q2, float *Q3, int dimX, int dimY, int dimZ, float tau);
float newU(float *U, float *U_old, int dimX, int dimY, int dimZ);
//float copyIm(float *A, float *U, int dimX, int dimY, int dimZ);
+#ifdef __cplusplus
+}
+#endif