Skip to content

Commit

Permalink
Merge pull request #603 from dkazanc/stripes
Browse files Browse the repository at this point in the history
Stripes detector and a mask generator
  • Loading branch information
carterbox committed Mar 23, 2023
2 parents 1455c26 + 36c7f46 commit f040f79
Show file tree
Hide file tree
Showing 15 changed files with 1,232 additions and 410 deletions.
12 changes: 12 additions & 0 deletions include/libtomo/stripe.h
Expand Up @@ -51,5 +51,17 @@
# define DLL
#endif

#include <stdbool.h>

DLL void
remove_stripe_sf(float* data, int dx, int dy, int dz, int size, int istart, int iend);

DLL int
stripesdetect3d_main_float(float* Input, float* Output, int window_halflength_vertical,
int ratio_radius, int ncores, int dimX, int dimY, int dimZ);

DLL int
stripesmask3d_main_float(float* Input, bool* Output, float threshold_val,
int stripe_length_min, int stripe_depth_min,
int stripe_width_min, float sensitivity, int ncores, int dimX,
int dimY, int dimZ);
2 changes: 0 additions & 2 deletions source/libtomo/misc/CMakeLists.txt
Expand Up @@ -9,8 +9,6 @@ tomopy_add_library(
morph.c
remove_ring.c
median_filt3d.c
utils.c
utils.h
${HEADERS})

find_package(OpenMP REQUIRED COMPONENTS C)
Expand Down
30 changes: 23 additions & 7 deletions source/libtomo/misc/median_filt3d.c
Expand Up @@ -47,9 +47,22 @@
#include <math.h>
#include <omp.h>
#include <stdlib.h>
#include <string.h>

#include "libtomo/median_filt3d.h"
#include "utils.h"

int floatcomp(const void* elem1, const void* elem2)
{
if(*(const float*)elem1 < *(const float*)elem2)
return -1;
return *(const float*)elem1 > *(const float*)elem2;
}
int uint16comp(const void* elem1, const void* elem2)
{
if(*(const unsigned short*)elem1 < *(const unsigned short*)elem2)
return -1;
return *(const unsigned short*)elem1 > *(const unsigned short*)elem2;
}

void
medfilt3D_float(float* Input, float* Output, int radius, int sizefilter_total,
Expand Down Expand Up @@ -90,7 +103,8 @@ medfilt3D_float(float* Input, float* Output, int radius, int sizefilter_total,
}
}
}
quicksort_float(ValVec, 0, sizefilter_total - 1); /* perform sorting */

qsort(ValVec, sizefilter_total, sizeof(float), floatcomp);

if(mu_threshold == 0.0F)
{
Expand Down Expand Up @@ -136,7 +150,7 @@ medfilt2D_float(float* Input, float* Output, int radius, int sizefilter_total,
counter++;
}
}
quicksort_float(ValVec, 0, sizefilter_total - 1); /* perform sorting */
qsort(ValVec, sizefilter_total, sizeof(float), floatcomp);

if(mu_threshold == 0.0F)
{
Expand Down Expand Up @@ -191,7 +205,8 @@ medfilt3D_uint16(unsigned short* Input, unsigned short* Output, int radius,
}
}
}
quicksort_uint16(ValVec, 0, sizefilter_total - 1); /* perform sorting */

qsort(ValVec, sizefilter_total, sizeof(unsigned short), uint16comp);

if(mu_threshold == 0.0F)
{
Expand Down Expand Up @@ -238,7 +253,8 @@ medfilt2D_uint16(unsigned short* Input, unsigned short* Output, int radius,
counter++;
}
}
quicksort_uint16(ValVec, 0, sizefilter_total - 1); /* perform sorting */

qsort(ValVec, sizefilter_total, sizeof(unsigned short), uint16comp);

if(mu_threshold == 0.0F)
{
Expand Down Expand Up @@ -268,7 +284,7 @@ medianfilter_main_float(float* Input, float* Output, int radius, float mu_thresh
diameter = (2 * radius + 1); /* diameter of the filter's kernel */
if(mu_threshold != 0.0)
{
copyIm(Input, Output, (long) (dimX), (long) (dimY), (long) (dimZ));
memcpy(Output, Input, dimX * dimY * dimZ * sizeof(float));
} /* copy input into output */

/* dealing here with a custom given number of cpu threads */
Expand Down Expand Up @@ -331,7 +347,7 @@ medianfilter_main_uint16(unsigned short* Input, unsigned short* Output, int radi
diameter = (2 * radius + 1); /* diameter of the filter's kernel */
if(mu_threshold != 0.0)
{
copyIm_unshort(Input, Output, (long) (dimX), (long) (dimY), (long) (dimZ));
memcpy(Output, Input, dimX * dimY * dimZ * sizeof(unsigned short));
} /* copy input into output */

/* dealing here with a custom given number of cpu threads */
Expand Down
202 changes: 0 additions & 202 deletions source/libtomo/misc/utils.c

This file was deleted.

65 changes: 0 additions & 65 deletions source/libtomo/misc/utils.h

This file was deleted.

0 comments on commit f040f79

Please sign in to comment.