locallab: speedup for locallab denoise
This commit is contained in:
parent
0a8f9dd15b
commit
1073172c31
@ -1142,7 +1142,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
|
||||
if (!memoryAllocationFailed) {
|
||||
if (nrQuality == QUALITY_STANDARD) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb, denoiseNestedLevels)) { //enhance mode
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
} else { /*if (nrQuality==QUALITY_HIGH)*/
|
||||
@ -1151,7 +1151,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
}
|
||||
|
||||
if (!memoryAllocationFailed) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb)) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *adecomp, noisevarchrom, madL, nullptr, 0, noisevarab_r, useNoiseCCurve, autoch, denoiseMethodRgb, denoiseNestedLevels)) {
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
|
||||
if (!memoryAllocationFailed) {
|
||||
if (nrQuality == QUALITY_STANDARD) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) { //enhance mode
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb, denoiseNestedLevels)) { //enhance mode
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
} else { /*if (nrQuality==QUALITY_HIGH)*/
|
||||
@ -1188,7 +1188,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
}
|
||||
|
||||
if (!memoryAllocationFailed) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb)) {
|
||||
if (!WaveletDenoiseAllAB(*Ldecomp, *bdecomp, noisevarchrom, madL, nullptr, 0, noisevarab_b, useNoiseCCurve, autoch, denoiseMethodRgb, denoiseNestedLevels)) {
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
}
|
||||
@ -1215,7 +1215,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
int edge = 0;
|
||||
|
||||
if (nrQuality == QUALITY_STANDARD) {
|
||||
if (!WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, nullptr, edge)) { //enhance mode
|
||||
if (!WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, nullptr, edge, denoiseNestedLevels)) { //enhance mode
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
} else { /*if (nrQuality==QUALITY_HIGH)*/
|
||||
@ -1224,7 +1224,7 @@ SSEFUNCTION void ImProcFunctions::RGB_denoise(int kall, Imagefloat * src, Imagef
|
||||
}
|
||||
|
||||
if (!memoryAllocationFailed) {
|
||||
if (!WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, nullptr, edge)) {
|
||||
if (!WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, nullptr, edge, denoiseNestedLevels)) {
|
||||
memoryAllocationFailed = true;
|
||||
}
|
||||
}
|
||||
@ -2476,7 +2476,7 @@ SSEFUNCTION bool ImProcFunctions::WaveletDenoiseAll_BiShrinkAB(wavelet_decomposi
|
||||
}
|
||||
|
||||
|
||||
bool ImProcFunctions::WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge)//mod JD
|
||||
bool ImProcFunctions::WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge, int denoiseNestedLevels)//mod JD
|
||||
|
||||
{
|
||||
|
||||
@ -2540,7 +2540,7 @@ bool ImProcFunctions::WaveletDenoiseAllL(wavelet_decomposition &WaveletCoeffs_L,
|
||||
|
||||
|
||||
bool ImProcFunctions::WaveletDenoiseAllAB(wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab,
|
||||
float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb)//mod JD
|
||||
float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, int denoiseNestedLevels)//mod JD
|
||||
|
||||
{
|
||||
|
||||
|
@ -292,7 +292,7 @@ public:
|
||||
static void strcurv_data (std::string retistr, int *s_datc, int &siz);
|
||||
void InverseContrast_Local (float ave, const struct local_contra& lco, const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy);
|
||||
|
||||
void DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy);
|
||||
void DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage &tmp1, int cx, int cy);
|
||||
|
||||
void ColorLight_Local (int call, LabImage * bufcolorig, LabImage * bufcoltra, float **buflight, float **bufchro, float ** buflightslid, int sp, float moy, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, bool locallutili, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, LUTf & cclocalcurve, float chprov, float cligh, const local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy);
|
||||
void InverseColorLight_Local (const struct local_params& lp, LabImage* original, LabImage* transformed, int cx, int cy);
|
||||
@ -334,8 +334,8 @@ public:
|
||||
void RGB_denoise_info (Imagefloat * src, Imagefloat * provicalc, bool isRAW, LUTf &gamcurve, float gam, float gamthresh, float gamslope, const procparams::DirPyrDenoiseParams & dnparams, const double expcomp, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float & maxblueaut, float &minredaut, float & minblueaut, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc, bool multiThread = false);
|
||||
void RGBtile_denoise (float * fLblox, int hblproc, float noisevar_Ldetail, float * nbrwt, float * blurbuffer ); //for DCT
|
||||
void RGBoutput_tile_row (float *bloxrow_L, float ** Ldetail, float ** tilemask_out, int height, int width, int top );
|
||||
bool WaveletDenoiseAllL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge);
|
||||
bool WaveletDenoiseAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb);
|
||||
bool WaveletDenoiseAllL (wavelet_decomposition &WaveletCoeffs_L, float *noisevarlum, float madL[8][3], float * vari, int edge, int denoiseNestedLevels);
|
||||
bool WaveletDenoiseAllAB (wavelet_decomposition &WaveletCoeffs_L, wavelet_decomposition &WaveletCoeffs_ab, float *noisevarchrom, float madL[8][3], float *variC, int local, float noisevar_ab, const bool useNoiseCCurve, bool autoch, bool denoiseMethodRgb, int denoiseNestedLevels);
|
||||
void WaveletDenoiseAll_info (int levwav, wavelet_decomposition &WaveletCoeffs_a,
|
||||
wavelet_decomposition &WaveletCoeffs_b, float **noisevarlum, float **noisevarchrom, float **noisevarhue, int width, int height, float noisevar_abr, float noisevar_abb, LabImage * noi, float &chaut, int &Nb, float &redaut, float &blueaut, float &maxredaut, float &maxblueaut, float &minredaut, float & minblueaut, int schoice, bool autoch, float &chromina, float &sigma, float &lumema, float &sigma_L, float &redyel, float &skinc, float &nsknc,
|
||||
float &maxchred, float &maxchblue, float &minchred, float &minchblue, int &nb, float &chau, float &chred, float &chblue, bool denoiseMethodRgb, bool multiThread);
|
||||
|
@ -35,6 +35,9 @@
|
||||
#ifdef _DEBUG
|
||||
#include "mytime.h"
|
||||
#endif
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#include "cplx_wavelet_dec.h"
|
||||
|
||||
@ -439,7 +442,7 @@ void ImProcFunctions::addGaNoise (LabImage *lab, LabImage *dst, const float mean
|
||||
}
|
||||
}
|
||||
|
||||
void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage* const tmp1, int cx, int cy)
|
||||
void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, LabImage* original, LabImage* transformed, const LabImage &tmp1, int cx, int cy)
|
||||
{
|
||||
// local denoise
|
||||
// BENCHFUN
|
||||
@ -448,7 +451,17 @@ void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, La
|
||||
#pragma omp parallel for schedule(dynamic,16) if (multiThread)
|
||||
|
||||
for (int y = 0; y < transformed->H; y++) {
|
||||
int loy = cy + y;
|
||||
const int loy = cy + y;
|
||||
const bool isZone0 = loy > lp.yc + lp.ly || loy < lp.yc - lp.lyT; // whole line is zone 0 => we can skip a lot of processing
|
||||
|
||||
if (isZone0) { // outside selection and outside transition zone => no effect, keep original values
|
||||
for (int x = 0; x < transformed->W; x++) {
|
||||
transformed->L[y][x] = original->L[y][x];
|
||||
transformed->a[y][x] = original->a[y][x];
|
||||
transformed->b[y][x] = original->b[y][x];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int x = 0; x < transformed->W; x++) {
|
||||
int lox = cx + x;
|
||||
@ -473,14 +486,14 @@ void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, La
|
||||
|
||||
if (call == 2) { //simpleprocess
|
||||
if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) {
|
||||
difL = tmp1->L[loy - begy][lox - begx] - original->L[y][x];
|
||||
difa = tmp1->a[loy - begy][lox - begx] - original->a[y][x];
|
||||
difb = tmp1->b[loy - begy][lox - begx] - original->b[y][x];
|
||||
difL = tmp1.L[loy - begy][lox - begx] - original->L[y][x];
|
||||
difa = tmp1.a[loy - begy][lox - begx] - original->a[y][x];
|
||||
difb = tmp1.b[loy - begy][lox - begx] - original->b[y][x];
|
||||
}
|
||||
} else { //dcrop
|
||||
difL = tmp1->L[y][x] - original->L[y][x];
|
||||
difa = tmp1->a[y][x] - original->a[y][x];
|
||||
difb = tmp1->b[y][x] - original->b[y][x];
|
||||
difL = tmp1.L[y][x] - original->L[y][x];
|
||||
difa = tmp1.a[y][x] - original->a[y][x];
|
||||
difb = tmp1.b[y][x] - original->b[y][x];
|
||||
|
||||
}
|
||||
|
||||
@ -499,14 +512,14 @@ void ImProcFunctions::DeNoise_Local (int call, const struct local_params& lp, La
|
||||
if (call == 2) { //simpleprocess
|
||||
|
||||
if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) {
|
||||
difL = tmp1->L[loy - begy][lox - begx] - original->L[y][x];
|
||||
difa = tmp1->a[loy - begy][lox - begx] - original->a[y][x];
|
||||
difb = tmp1->b[loy - begy][lox - begx] - original->b[y][x];
|
||||
difL = tmp1.L[loy - begy][lox - begx] - original->L[y][x];
|
||||
difa = tmp1.a[loy - begy][lox - begx] - original->a[y][x];
|
||||
difb = tmp1.b[loy - begy][lox - begx] - original->b[y][x];
|
||||
}
|
||||
} else { //dcrop
|
||||
difL = tmp1->L[y][x] - original->L[y][x];
|
||||
difa = tmp1->a[y][x] - original->a[y][x];
|
||||
difb = tmp1->b[y][x] - original->b[y][x];
|
||||
difL = tmp1.L[y][x] - original->L[y][x];
|
||||
difa = tmp1.a[y][x] - original->a[y][x];
|
||||
difb = tmp1.b[y][x] - original->b[y][x];
|
||||
|
||||
}
|
||||
|
||||
@ -3793,17 +3806,22 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
levred = 7;
|
||||
}
|
||||
|
||||
#ifdef _OPENMP
|
||||
const int numThreads = omp_get_max_threads();
|
||||
#else
|
||||
const int numThreads = 1;
|
||||
|
||||
#endif
|
||||
if (call == 1) {
|
||||
LabImage *tmp1 = new LabImage (transformed->W, transformed->H);
|
||||
LabImage tmp1(transformed->W, transformed->H);
|
||||
int GW = transformed->W;
|
||||
int GH = transformed->H;
|
||||
|
||||
|
||||
for (int ir = 0; ir < GH; ir++)
|
||||
for (int jr = 0; jr < GW; jr++) {
|
||||
tmp1->L[ir][jr] = original->L[ir][jr];
|
||||
tmp1->a[ir][jr] = original->a[ir][jr];
|
||||
tmp1->b[ir][jr] = original->b[ir][jr];
|
||||
tmp1.L[ir][jr] = original->L[ir][jr];
|
||||
tmp1.a[ir][jr] = original->a[ir][jr];
|
||||
tmp1.b[ir][jr] = original->b[ir][jr];
|
||||
}
|
||||
|
||||
int DaubLen = 6;
|
||||
@ -3811,28 +3829,28 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
|
||||
int levwavL = levred;
|
||||
int skip = 1;
|
||||
wavelet_decomposition* Ldecomp = new wavelet_decomposition (tmp1->L[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
wavelet_decomposition* adecomp = new wavelet_decomposition (tmp1->a[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
wavelet_decomposition* bdecomp = new wavelet_decomposition (tmp1->b[0], tmp1->W, tmp1->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
|
||||
wavelet_decomposition Ldecomp(tmp1.L[0], tmp1.W, tmp1.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
wavelet_decomposition adecomp(tmp1.a[0], tmp1.W, tmp1.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
wavelet_decomposition bdecomp(tmp1.b[0], tmp1.W, tmp1.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
|
||||
float madL[8][3];
|
||||
float madab[8][3];
|
||||
int edge;
|
||||
|
||||
if (!Ldecomp->memoryAllocationFailed) {
|
||||
|
||||
if (!Ldecomp.memoryAllocationFailed) {
|
||||
#pragma omp parallel for collapse(2) schedule(dynamic,1)
|
||||
for (int lvl = 0; lvl < levred; lvl++) {
|
||||
for (int dir = 1; dir < 4; dir++) {
|
||||
int Wlvl_L = Ldecomp->level_W (lvl);
|
||||
int Hlvl_L = Ldecomp->level_H (lvl);
|
||||
int Wlvl_L = Ldecomp.level_W (lvl);
|
||||
int Hlvl_L = Ldecomp.level_H (lvl);
|
||||
|
||||
float ** WavCoeffs_L = Ldecomp->level_coeffs (lvl);
|
||||
float ** WavCoeffs_L = Ldecomp.level_coeffs (lvl);
|
||||
|
||||
madL[lvl][dir - 1] = SQR (Mad (WavCoeffs_L[dir], Wlvl_L * Hlvl_L));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ind = 0;
|
||||
float vari[levred];
|
||||
|
||||
@ -3869,13 +3887,13 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
|
||||
float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL
|
||||
|
||||
WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge);
|
||||
WaveletDenoiseAllL (Ldecomp, noisevarlum, madL, vari, edge, numThreads);
|
||||
}
|
||||
}
|
||||
|
||||
float variC[levred];
|
||||
|
||||
if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) {
|
||||
if (!adecomp.memoryAllocationFailed && !bdecomp.memoryAllocationFailed) {
|
||||
if (levred == 7) {
|
||||
edge = 2;
|
||||
variC[0] = SQR (lp.noisecf / 10.0);
|
||||
@ -3921,103 +3939,85 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
}
|
||||
|
||||
float noisevarab_r = 100.f; //SQR(lp.noisecc / 10.0);
|
||||
WaveletDenoiseAllAB (*Ldecomp, *adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false);
|
||||
WaveletDenoiseAllAB (*Ldecomp, *bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false);
|
||||
WaveletDenoiseAllAB (Ldecomp, adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false, numThreads);
|
||||
WaveletDenoiseAllAB (Ldecomp, bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false, numThreads);
|
||||
delete[] noisevarchrom;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!Ldecomp->memoryAllocationFailed) {
|
||||
if (!Ldecomp.memoryAllocationFailed) {
|
||||
|
||||
Ldecomp->reconstruct (tmp1->L[0]);
|
||||
Ldecomp.reconstruct (tmp1.L[0]);
|
||||
}
|
||||
|
||||
if (!adecomp->memoryAllocationFailed) {
|
||||
if (!adecomp.memoryAllocationFailed) {
|
||||
|
||||
adecomp->reconstruct (tmp1->a[0]);
|
||||
adecomp.reconstruct (tmp1.a[0]);
|
||||
}
|
||||
|
||||
if (!bdecomp->memoryAllocationFailed) {
|
||||
if (!bdecomp.memoryAllocationFailed) {
|
||||
|
||||
bdecomp->reconstruct (tmp1->b[0]);
|
||||
bdecomp.reconstruct (tmp1.b[0]);
|
||||
}
|
||||
|
||||
DeNoise_Local (call, lp, original, transformed, tmp1, cx, cy);
|
||||
delete tmp1;
|
||||
delete Ldecomp;
|
||||
delete adecomp;
|
||||
delete bdecomp;
|
||||
}
|
||||
|
||||
LabImage *bufwv;
|
||||
} else if (call == 2) { //simpleprocess
|
||||
|
||||
if (call == 2) { //simpleprocess
|
||||
int GW = transformed->W;
|
||||
int GH = transformed->H;
|
||||
int bfh = int (lp.ly + lp.lyT) + del; //bfw bfh real size of square zone
|
||||
int bfw = int (lp.lx + lp.lxL) + del;
|
||||
bufwv = new LabImage (bfw, bfh);
|
||||
LabImage bufwv(bfw, bfh);
|
||||
bufwv.clear(true);
|
||||
|
||||
int yStart = lp.yc - lp.lyT - cy;
|
||||
int yEnd = lp.yc + lp.ly - cy;
|
||||
int xStart = lp.xc - lp.lxL - cx;
|
||||
int xEnd = lp.xc + lp.lx - cx;
|
||||
int begy = lp.yc - lp.lyT;
|
||||
int begx = lp.xc - lp.lxL;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#pragma omp parallel for schedule(dynamic,16)
|
||||
#endif
|
||||
|
||||
for (int ir = 0; ir < bfh; ir++) //fill with 0
|
||||
for (int jr = 0; jr < bfw; jr++) {
|
||||
bufwv->L[ir][jr] = 0.f;
|
||||
bufwv->a[ir][jr] = 0.f;
|
||||
bufwv->b[ir][jr] = 0.f;
|
||||
for (int y = yStart; y < yEnd ; y++) {
|
||||
int loy = cy + y;
|
||||
|
||||
for (int x = xStart, lox = cx + x; x < xEnd; x++, lox++) {
|
||||
bufwv.L[loy - begy][lox - begx] = original->L[y][x];//fill square buffer with datas
|
||||
bufwv.a[loy - begy][lox - begx] = original->a[y][x];//fill square buffer with datas
|
||||
bufwv.b[loy - begy][lox - begx] = original->b[y][x];//fill square buffer with datas
|
||||
}
|
||||
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < transformed->H ; y++) //{
|
||||
for (int x = 0; x < transformed->W; x++) {
|
||||
int lox = cx + x;
|
||||
int loy = cy + y;
|
||||
int begx = int (lp.xc - lp.lxL);
|
||||
int begy = int (lp.yc - lp.lyT);
|
||||
|
||||
if (lox >= (lp.xc - lp.lxL) && lox < (lp.xc + lp.lx) && loy >= (lp.yc - lp.lyT) && loy < (lp.yc + lp.ly)) {
|
||||
bufwv->L[loy - begy][lox - begx] = original->L[y][x];//fill square buffer with datas
|
||||
bufwv->a[loy - begy][lox - begx] = original->a[y][x];//fill square buffer with datas
|
||||
bufwv->b[loy - begy][lox - begx] = original->b[y][x];//fill square buffer with datas
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int DaubLen = 6;
|
||||
int wavNestedLevels = 1;
|
||||
|
||||
int levwavL = levred;
|
||||
int skip = 1;
|
||||
wavelet_decomposition* Ldecomp = new wavelet_decomposition (bufwv->L[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
wavelet_decomposition* adecomp = new wavelet_decomposition (bufwv->a[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
wavelet_decomposition* bdecomp = new wavelet_decomposition (bufwv->b[0], bufwv->W, bufwv->H, levwavL, 1, skip, max (1, wavNestedLevels), DaubLen);
|
||||
wavelet_decomposition Ldecomp(bufwv.L[0], bufwv.W, bufwv.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
wavelet_decomposition adecomp(bufwv.a[0], bufwv.W, bufwv.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
wavelet_decomposition bdecomp(bufwv.b[0], bufwv.W, bufwv.H, levwavL, 1, skip, numThreads, DaubLen);
|
||||
|
||||
float madL[8][3];
|
||||
float madab[8][3];
|
||||
int edge;
|
||||
|
||||
if (!Ldecomp->memoryAllocationFailed) {
|
||||
|
||||
if (!Ldecomp.memoryAllocationFailed) {
|
||||
#pragma omp parallel for collapse(2) schedule(dynamic,1)
|
||||
for (int lvl = 0; lvl < levred; lvl++) {
|
||||
for (int dir = 1; dir < 4; dir++) {
|
||||
int Wlvl_L = Ldecomp->level_W (lvl);
|
||||
int Hlvl_L = Ldecomp->level_H (lvl);
|
||||
int Wlvl_L = Ldecomp.level_W (lvl);
|
||||
int Hlvl_L = Ldecomp.level_H (lvl);
|
||||
|
||||
float ** WavCoeffs_L = Ldecomp->level_coeffs (lvl);
|
||||
float ** WavCoeffs_L = Ldecomp.level_coeffs (lvl);
|
||||
|
||||
madL[lvl][dir - 1] = SQR (Mad (WavCoeffs_L[dir], Wlvl_L * Hlvl_L));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ind = 0;
|
||||
|
||||
float vari[levred];
|
||||
@ -4057,14 +4057,14 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
|
||||
float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL
|
||||
|
||||
WaveletDenoiseAllL (*Ldecomp, noisevarlum, madL, vari, edge);
|
||||
WaveletDenoiseAllL (Ldecomp, noisevarlum, madL, vari, edge, numThreads);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float variC[levred];
|
||||
|
||||
if (!adecomp->memoryAllocationFailed && !bdecomp->memoryAllocationFailed) {
|
||||
if (!adecomp.memoryAllocationFailed && !bdecomp.memoryAllocationFailed) {
|
||||
|
||||
if (levred == 7) {
|
||||
edge = 2;
|
||||
@ -4111,41 +4111,29 @@ void ImProcFunctions::Lab_Local (int call, int sp, float** shbuffer, LabImage *
|
||||
|
||||
|
||||
float noisevarab_r = 100.f; //SQR(lp.noisecc / 10.0);
|
||||
WaveletDenoiseAllAB (*Ldecomp, *adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false);
|
||||
WaveletDenoiseAllAB (*Ldecomp, *bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false);
|
||||
WaveletDenoiseAllAB (Ldecomp, adecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false, numThreads);
|
||||
WaveletDenoiseAllAB (Ldecomp, bdecomp, noisevarchrom, madL, variC, edge, noisevarab_r, false, false, false, numThreads);
|
||||
delete[] noisevarchrom;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!Ldecomp.memoryAllocationFailed) {
|
||||
|
||||
if (!Ldecomp->memoryAllocationFailed) {
|
||||
|
||||
Ldecomp->reconstruct (bufwv->L[0]);
|
||||
Ldecomp.reconstruct (bufwv.L[0]);
|
||||
}
|
||||
|
||||
if (!adecomp->memoryAllocationFailed) {
|
||||
if (!adecomp.memoryAllocationFailed) {
|
||||
|
||||
adecomp->reconstruct (bufwv->a[0]);
|
||||
adecomp.reconstruct (bufwv.a[0]);
|
||||
}
|
||||
|
||||
if (!bdecomp->memoryAllocationFailed) {
|
||||
if (!bdecomp.memoryAllocationFailed) {
|
||||
|
||||
bdecomp->reconstruct (bufwv->b[0]);
|
||||
bdecomp.reconstruct (bufwv.b[0]);
|
||||
}
|
||||
|
||||
DeNoise_Local (call, lp, original, transformed, bufwv, cx, cy);
|
||||
delete bufwv;
|
||||
delete Ldecomp;
|
||||
delete adecomp;
|
||||
delete bdecomp;
|
||||
|
||||
bufwv = nullptr;
|
||||
Ldecomp = nullptr;
|
||||
adecomp = nullptr;
|
||||
bdecomp = nullptr;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ SSEFUNCTION void ImProcFunctions::ip_wavelet(LabImage * lab, LabImage * dst, int
|
||||
vari[3] = max(0.0001f, vari[3]);
|
||||
float* noisevarlum = nullptr; // we need a dummy to pass it to WaveletDenoiseAllL
|
||||
|
||||
WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge);
|
||||
WaveletDenoiseAllL(*Ldecomp, noisevarlum, madL, vari, edge, 1);
|
||||
}
|
||||
|
||||
ind = 1;
|
||||
|
@ -78,6 +78,17 @@ public:
|
||||
allocLab(W, H);
|
||||
};
|
||||
|
||||
void clear(bool multiThread = false) {
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for if(multiThread)
|
||||
#endif
|
||||
for(int i = 0; i < H; ++i) {
|
||||
for(int j = 0; j < W; ++j) {
|
||||
L[i][j] = a[i][j] = b[i][j] = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user