Skip to content

Commit

Permalink
QuantMap::Add binary thresholding for mask creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
scholand authored and uecker committed Feb 2, 2021
1 parent c37a855 commit 7a292fd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/threshold.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,18 @@ static void hard_thresh(unsigned int D, const long dims[D], float lambda, comple
outf[i] = inf[i] > lambda ? inf[i] : 0.;
}

static void binary_thresh(unsigned int D, const long dims[D], float lambda, complex float* out, const complex float* in)
{
long size = md_calc_size(DIMS, dims) * 2;

const float* inf = (const float*)in;
float* outf = (float*)out;

#pragma omp parallel for
for (long i = 0; i < size; i++)
outf[i] = inf[i] > lambda ? 1. : 0.;
}



static const char usage_str[] = "lambda <input> <output>";
Expand All @@ -125,7 +137,7 @@ int main_threshold(int argc, char* argv[argc])
{
unsigned int flags = 0;

enum th_type { NONE, WAV, LLR, DFW, MPDFW, HARD } th_type = NONE;
enum th_type { NONE, WAV, LLR, DFW, MPDFW, HARD, BINARY } th_type = NONE;
int llrblk = 8;


Expand All @@ -135,6 +147,7 @@ int main_threshold(int argc, char* argv[argc])
OPT_SELECT('W', enum th_type, &th_type, WAV, "daubechies wavelet soft-thresholding"),
OPT_SELECT('L', enum th_type, &th_type, LLR, "locally low rank soft-thresholding"),
OPT_SELECT('D', enum th_type, &th_type, DFW, "divergence-free wavelet soft-thresholding"),
OPT_SELECT('B', enum th_type, &th_type, BINARY, "thresholding with binary output"),
OPT_UINT('j', &flags, "bitmask", "joint soft-thresholding"),
OPT_INT('b', &llrblk, "blocksize", "locally low rank block size"),
};
Expand Down Expand Up @@ -167,6 +180,10 @@ int main_threshold(int argc, char* argv[argc])
case HARD:
hard_thresh(N, dims, lambda, odata, idata);
break;

case BINARY:
binary_thresh(N, dims, lambda, odata, idata);
break;

default:
md_zsoftthresh(N, dims, lambda, flags, odata, idata);
Expand Down

0 comments on commit 7a292fd

Please sign in to comment.