예제 #1
0
파일: threshold.c 프로젝트: hcmh/bart
int main_threshold(int argc, char* argv[])
{
	unsigned int flags = 0;
        
	enum th_type { NONE, WAV, LLR, DFW, MPDFW, HARD } th_type = NONE;
	int llrblk = 8;


	const struct opt_s opts[] = {

		OPT_SELECT('H', enum th_type, &th_type, HARD, "hard thresholding"),
		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_UINT('j', &flags, "bitmask", "joint soft-thresholding"),
		OPT_INT('b', &llrblk, "blocksize", "locally low rank block size"),
	};

	cmdline(&argc, argv, 3, 3, usage_str, help_str, ARRAY_SIZE(opts), opts);

	num_init();

	const int N = DIMS;
	long dims[N];
	complex float* idata = load_cfl(argv[2], N, dims);
	complex float* odata = create_cfl(argv[3], N, dims);

	float lambda = atof(argv[1]);

	switch (th_type) {

		case WAV:
			wthresh(N, dims, lambda, flags, odata, idata);
			break;

		case LLR:
			lrthresh(N, dims, llrblk, lambda, flags, odata, idata);
			break;
                        
		case DFW:
			dfthresh(N, dims, lambda, odata, idata);
			break;

		case HARD:
			hard_thresh(N, dims, lambda, odata, idata);
			break;

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

	}


	unmap_cfl(N, dims, idata);
	unmap_cfl(N, dims, odata);
	return 0;
}
예제 #2
0
void wavelet3_thresh(unsigned int N, float lambda, unsigned int flags, const long shifts[N], const long dims[N], complex float* out, const complex float* in, const long minsize[N], long flen, const float filter[2][2][flen])
{
	unsigned long coeffs = wavelet_coeffs(N, flags, dims, minsize, flen);

	long istr[N];
	md_calc_strides(N, istr, dims, CFL_SIZE);

	complex float* tmp = md_alloc_sameplace(1, MD_DIMS(coeffs), CFL_SIZE, out);

	fwt(N, flags, shifts, dims, tmp, istr, in, minsize, flen, filter);
	md_zsoftthresh(1, MD_DIMS(coeffs), lambda, 0u, tmp, tmp);
	iwt(N, flags, shifts, dims, istr, out, tmp, minsize, flen, filter);

	md_free(tmp);
}
예제 #3
0
파일: wavelet.c 프로젝트: hcmh/bart
void wavelet_thresh(unsigned int N, float lambda, unsigned int flags, unsigned int jflags, const long shifts[N], const long dims[N], complex float* out, const complex float* in, const long minsize[N], long flen, const float filter[2][2][flen])
{
	assert(0 == (flags & jflags));

	long wdims[N];
	wavelet_coeffs2(N, flags, wdims, dims, minsize, flen);

	long wstr[N];
	md_calc_strides(N, wstr, wdims, CFL_SIZE);

	complex float* tmp = md_alloc_sameplace(N, wdims, CFL_SIZE, out);

	long str[N];
	md_calc_strides(N, str, dims, CFL_SIZE);

	fwt2(N, flags, shifts, wdims, wstr, tmp, dims, str, in, minsize, flen, filter);

	md_zsoftthresh(N, wdims, lambda, jflags, tmp, tmp);

	iwt2(N, flags, shifts, dims, str, out, wdims, wstr, tmp, minsize, flen, filter);

	md_free(tmp);
}