c++ - CImg - Saliency with spectral approach -


i trying implement spectral approach saliency of image cimg, i'm having trouble getting there. might seems repost question (spectral residual saliency detection in c++ cimg) think got right 2 mistakes question (atan2 , fft arguments).

here's code:

int main(int argc, char * argv[]) {      const char * input_file = "img/pic.png";      cimg<float> input = cimg<float>(input_file);     const cimg<float> mask(3,3,1,1,1.0f/9.0f);      resize_fft(input); // resize fft     cimg<float> gray = any2gray(input); // single channel grayscale      cimglist<float> fft = gray.get_fft();      cimg<float> amp = (fft[0].get_pow(2) + fft[1].get_pow(2)).get_sqrt();     cimg<float> amp_log = (amp + 1.0f).get_log().get_normalize(0, 255);      cimg<float> phase = fft[1].get_atan2(fft[0]);     cimg<float> residual = amp_log - amp_log.get_convolve(mask);     cimg<float> real = residual.get_exp();     cimg<float>::fft(real, phase, true);      real.save("img/001.png");     real.normalize(0, 255).save("img/002.png");      return 1; } 

both save pictures 001 , 002 end being noise-like picture, still in frequency space. don't what's wrong i'm doing, if yuo guys can me ?

thanks.

firstly, obvious forget smooth real gaussian filter.

secondly, line cimg<float>::fft(real, phase, true); suspectable. don't know cimg library can understand expressing. when inverse fft, think both real part , imaginary part wrong. formulae in paper kind of misleading, reading the matlab code clearer.
if familiar complex number, find getting variable phase not necessary here.
pseudo code replacing line here:

fft[0] = fft[0] ./ amp .* residual; fft[1] = fft[1] ./ amp .* residual; //inverse fourier transform cimg<float>::fft(fft[0], fft[1], true); real = fft[0].get_pow(2) + fft[1].get_pow(2); real.get_convolve(gaussian filter sigma = 8) 

all operators left dot mean element-wise operation.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -