From d486d70a9c0dddbcb36aaf5c03e06512cb83b602 Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Tue, 20 Aug 2024 20:57:10 +0200 Subject: [PATCH] . --- CImg.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/CImg.h b/CImg.h index f7002752..92f58de9 100644 --- a/CImg.h +++ b/CImg.h @@ -32496,25 +32496,25 @@ namespace cimg_library { } else { // Orthogonal Matching Pursuit: Orthogonal projection step. - weights(signal,max_atom) = 1; // Used as a marker only. + weights(signal,max_atom) = 1; // Use only as a marker unsigned int nb_weights = 0; cimg_forY(weights,atom) if (weights(signal,atom)) ++nb_weights; - CImg sD(nb_weights,dictionary._height); - CImg inds(nb_weights); - int sd = 0; + CImg sub_dictionary(nb_weights,dictionary._height); + CImg sub_atoms(nb_weights); + int ind = 0; cimg_forY(weights,atom) if (weights(signal,atom)) { - cimg_forY(sD,s) sD(sd,s) = dictionary(atom,s); - inds[sd++] = atom; + cimg_forY(sub_dictionary,s) sub_dictionary(ind,s) = dictionary(atom,s); + sub_atoms[ind++] = atom; } - R0.get_solve(sD).move_to(sD); // sD is now a one-column vector of weights + const CImg sub_weights = R0.get_solve(sub_dictionary); - // Recompute residual signal. + // Recompute residual signal according to the projected weights. R = R0; - cimg_forY(sD,atom) { - const Tfloat weight = sD[atom]; - const unsigned int ind = inds[atom]; - weights(signal,ind) = weight; - cimg_forY(R,s) R[s]-=weight*dictionary(ind,s); + cimg_forY(sub_weights,sub_atom) { + const Tfloat weight = sub_weights[sub_atom]; + const unsigned int atom = sub_atoms[sub_atom]; + weights(signal,atom) = weight; + cimg_forY(R,s) R[s]-=weight*dictionary(atom,s); } residual = R.magnitude(2)/R._height; is_orthoproj = true; @@ -32526,15 +32526,15 @@ namespace cimg_library { unsigned int nb_weights = 0; cimg_forY(weights,atom) if (weights(signal,atom)) ++nb_weights; if (nb_weights) { // Avoid degenerated case where 0 coefs are used - CImg sD(nb_weights,dictionary._height); - CImg inds(nb_weights); - int sd = 0; + CImg sub_dictionary(nb_weights,dictionary._height); + CImg sub_atoms(nb_weights); + int ind = 0; cimg_forY(weights,atom) if (weights(signal,atom)) { - cimg_forY(sD,s) sD(sd,s) = dictionary(atom,s); - inds[sd++] = atom; + cimg_forY(sub_dictionary,s) sub_dictionary(ind,s) = dictionary(atom,s); + sub_atoms[ind++] = atom; } - R0.get_solve(sD).move_to(sD); - cimg_forY(sD,atom) weights(signal,inds[atom]) = sD[atom]; + const CImg sub_weights = R0.get_solve(sub_dictionary); + cimg_forY(sub_weights,sub_atom) weights(signal,sub_atoms[sub_atom]) = sub_weights[sub_atom]; } } }