summaryrefslogtreecommitdiffstats
path: root/src/Matlab
diff options
context:
space:
mode:
authorDaniil Kazantsev <dkazanc@hotmail.com>2019-09-04 13:37:08 +0100
committerGitHub <noreply@github.com>2019-09-04 13:37:08 +0100
commit4fb89fcc4719f24b38a777ed6c7204f5761770ad (patch)
treef62e25877912d2cebb18a925886d86dcabfe32a4 /src/Matlab
parente2d85c8557733174690da77f712a0c0a7c2d26e0 (diff)
parente2601be8f44c09ff21f259d0ce3219bfd5918f12 (diff)
downloadregularization-4fb89fcc4719f24b38a777ed6c7204f5761770ad.tar.gz
regularization-4fb89fcc4719f24b38a777ed6c7204f5761770ad.tar.bz2
regularization-4fb89fcc4719f24b38a777ed6c7204f5761770ad.tar.xz
regularization-4fb89fcc4719f24b38a777ed6c7204f5761770ad.zip
Merge pull request #130 from vais-ral/nltv_fix
NLTV fix for nonsquare images
Diffstat (limited to 'src/Matlab')
-rw-r--r--src/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c30
-rw-r--r--src/Matlab/mex_compile/regularisers_CPU/PatchSelect.c24
2 files changed, 27 insertions, 27 deletions
diff --git a/src/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c b/src/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c
index 34b9915..a5fb1df 100644
--- a/src/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c
+++ b/src/Matlab/mex_compile/regularisers_CPU/Nonlocal_TV.c
@@ -1,11 +1,11 @@
/*
* This work is part of the Core Imaging Library developed by
* Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC and Diamond Light Source Ltd.
+ * Facilities Council, STFC and Diamond Light Source Ltd.
*
* Copyright 2017 Daniil Kazantsev
* Copyright 2017 Srikanth Nagella, Edoardo Pasca
- * Copyright 2018 Diamond Light Source Ltd.
+ * Copyright 2018 Diamond Light Source Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,12 +35,12 @@
* 2. AR_i - indeces of i neighbours
* 3. AR_j - indeces of j neighbours
* 4. AR_k - indeces of k neighbours (0 - for 2D case)
- * 5. Weights_ij(k) - associated weights
+ * 5. Weights_ij(k) - associated weights
* 6. regularisation parameter
- * 7. iterations number
-
+ * 7. iterations number
+
* Output:
- * 1. denoised image/volume
+ * 1. denoised image/volume
* Elmoataz, Abderrahim, Olivier Lezoray, and Sébastien Bougleux. "Nonlocal discrete regularization on weighted graphs: a framework for image and manifold processing." IEEE Trans. Image Processing 17, no. 7 (2008): 1047-1060.
*/
@@ -54,11 +54,11 @@ void mexFunction(
const mwSize *dim_array;
const mwSize *dim_array2;
float *A_orig, *Output=NULL, *Weights, lambda;
-
+
dim_array = mxGetDimensions(prhs[0]);
dim_array2 = mxGetDimensions(prhs[1]);
number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
+
/*Handling Matlab input data*/
A_orig = (float *) mxGetData(prhs[0]); /* a 2D image or a set of 2D images (3D stack) */
H_i = (unsigned short *) mxGetData(prhs[1]); /* indeces of i neighbours */
@@ -67,14 +67,14 @@ void mexFunction(
Weights = (float *) mxGetData(prhs[4]); /* weights for patches */
lambda = (float) mxGetScalar(prhs[5]); /* regularisation parameter */
IterNumb = (int) mxGetScalar(prhs[6]); /* the number of iterations */
-
- dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
-
+
+ dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
+
/*****2D INPUT *****/
if (number_of_dims == 2) {
- dimZ = 0;
+ dimZ = 0;
NumNeighb = dim_array2[2];
- Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
+ Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL));
}
/*****3D INPUT *****/
/****************************************************/
@@ -82,7 +82,7 @@ void mexFunction(
NumNeighb = dim_array2[3];
Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL));
}
-
+
/* run the main function here */
- Nonlocal_TV_CPU_main(A_orig, Output, H_i, H_j, H_k, Weights, dimX, dimY, dimZ, NumNeighb, lambda, IterNumb);
+ Nonlocal_TV_CPU_main(A_orig, Output, H_i, H_j, H_k, Weights, dimX, dimY, dimZ, NumNeighb, lambda, IterNumb, 0);
}
diff --git a/src/Matlab/mex_compile/regularisers_CPU/PatchSelect.c b/src/Matlab/mex_compile/regularisers_CPU/PatchSelect.c
index 1acab29..84b08dd 100644
--- a/src/Matlab/mex_compile/regularisers_CPU/PatchSelect.c
+++ b/src/Matlab/mex_compile/regularisers_CPU/PatchSelect.c
@@ -1,11 +1,11 @@
/*
* This work is part of the Core Imaging Library developed by
* Visual Analytics and Imaging System Group of the Science Technology
- * Facilities Council, STFC and Diamond Light Source Ltd.
+ * Facilities Council, STFC and Diamond Light Source Ltd.
*
* Copyright 2017 Daniil Kazantsev
* Copyright 2017 Srikanth Nagella, Edoardo Pasca
- * Copyright 2018 Diamond Light Source Ltd.
+ * Copyright 2018 Diamond Light Source Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,14 +53,14 @@ void mexFunction(
int number_of_dims, SearchWindow, SimilarWin, NumNeighb;
mwSize dimX, dimY, dimZ;
const mwSize *dim_array;
- unsigned short *H_i=NULL, *H_j=NULL, *H_k=NULL;
+ unsigned short *H_i=NULL, *H_j=NULL, *H_k=NULL;
float *A, *Weights = NULL, h;
mwSize dim_array2[3]; /* for 2D data */
mwSize dim_array3[4]; /* for 3D data */
-
+
dim_array = mxGetDimensions(prhs[0]);
number_of_dims = mxGetNumberOfDimensions(prhs[0]);
-
+
/*Handling Matlab input data*/
A = (float *) mxGetData(prhs[0]); /* a 2D or 3D image/volume */
SearchWindow = (int) mxGetScalar(prhs[1]); /* Large Searching window */
@@ -71,22 +71,22 @@ void mexFunction(
dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2];
dim_array2[0] = dimX; dim_array2[1] = dimY; dim_array2[2] = NumNeighb; /* 2D case */
dim_array3[0] = dimX; dim_array3[1] = dimY; dim_array3[2] = dimZ; dim_array3[3] = NumNeighb; /* 3D case */
-
+
/****************2D INPUT ***************/
if (number_of_dims == 2) {
- dimZ = 0;
+ dimZ = 0;
H_i = (unsigned short*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array2, mxUINT16_CLASS, mxREAL));
H_j = (unsigned short*)mxGetPr(plhs[1] = mxCreateNumericArray(3, dim_array2, mxUINT16_CLASS, mxREAL));
Weights = (float*)mxGetPr(plhs[2] = mxCreateNumericArray(3, dim_array2, mxSINGLE_CLASS, mxREAL));
}
/****************3D INPUT ***************/
- if (number_of_dims == 3) {
+ if (number_of_dims == 3) {
H_i = (unsigned short*)mxGetPr(plhs[0] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
H_j = (unsigned short*)mxGetPr(plhs[1] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
H_k = (unsigned short*)mxGetPr(plhs[2] = mxCreateNumericArray(4, dim_array3, mxUINT16_CLASS, mxREAL));
- Weights = (float*)mxGetPr(plhs[3] = mxCreateNumericArray(4, dim_array3, mxSINGLE_CLASS, mxREAL));
+ Weights = (float*)mxGetPr(plhs[3] = mxCreateNumericArray(4, dim_array3, mxSINGLE_CLASS, mxREAL));
}
-
- PatchSelect_CPU_main(A, H_i, H_j, H_k, Weights, (long)(dimX), (long)(dimY), (long)(dimZ), SearchWindow, SimilarWin, NumNeighb, h, 0);
-
+
+ PatchSelect_CPU_main(A, H_i, H_j, H_k, Weights, (long)(dimX), (long)(dimY), (long)(dimZ), SearchWindow, SimilarWin, NumNeighb, h);
+
}