Code Monkey home page Code Monkey logo

Comments (9)

mdswyz avatar mdswyz commented on August 14, 2024 1

Thank you very much for your timely reply, which is very helpful to me!

from pisr.

wonkyunglee avatar wonkyunglee commented on August 14, 2024

Hello, thanks for your attention.
Actually, the codes for obtaining high-freq signals are not organized well because we implemented it in the jupyter-notebook file.
Instead of sharing the full code, I gonna provide you the core functions.

def get_spectrum(img):
    f = np.fft.fft2(img)
    fshift = np.fft.fftshift(f)
    magnitude_spectrum = 20*np.log(np.abs(fshift))
    return magnitude_spectrum.squeeze()

def plot_spectrum(lr_upsampled, hr, encoded_lr_upsampled, notim_encoded_lr_upsampled):
    magnitude_spectrum_hr = get_spectrum(hr)
    magnitude_spectrum_lr = get_spectrum(lr_upsampled)
    magnitude_spectrum_encoded_lr = get_spectrum(encoded_lr_upsampled)
    magnitude_spectrum_notim = get_spectrum(notim_encoded_lr_upsampled)
    
    # skip detailed codes. #
    plt.plot(magnitude_spectrum_lr[h, w-m:w+m])
    plt.plot(magnitude_spectrum_encoded_lr[h, w-m:w+m])
    plt.plot(magnitude_spectrum_notim[h, w-m:w+m])
    plt.show()

I hope those are helpful.

from pisr.

mdswyz avatar mdswyz commented on August 14, 2024

I have some problems that I hope you can solve.

  1. In "magnitude_spectrum_hr[h,w - m:w + m]", h and w should be the height and width of the input image, but I don't understand what "m" means.

  2. I see that all the low resolution (lr) images in the code are suffixed with "_upsampled", which means that the results obtained in Fig. 3 in the paper are compared after being upsampled on the low resolution images? If so, which upsampling method is used.

Looking forward to your reply again.

from pisr.

wonkyunglee avatar wonkyunglee commented on August 14, 2024
  1. First of all, the input of the function is a cropped image whose size is 200 by 200 (for the HR case).
    As you know, the output of the function get_spectrum() has the same shape of the image, which is 200 by 200 in this case.
    For plotting the magnitude spectrum like the left-bottom of Figure 3, we only need the 100th row (i.e., v=0 results from the fft-shift) of the output, therefore we set h to 100.
    Also, we set w and m to 100 and 50, respectively, I'll explain the reason in the next answer.

  2. If we'd like to plot both magnitude spectrums from HR and LR into one figure, we need to calibrate the frequency axis of them because the shapes of each spectrum are (200, 200) and (100, 100), respectively. Therefore, we upsampled LR and encoded LR images by two times with a bilinear interpolation method.
    After the upsampling, the magnitude components at u > 150 and u < 50 are not originated from the LR (and encoded LR) images. This led us to set w and m to 100 and 50.

from pisr.

mdswyz avatar mdswyz commented on August 14, 2024

Thank you for your kind and attentive reply!

Since I am not solid enough in Fourier transform, I may make mistakes when testing my images. Here are a few questions. If the size of my high-resolution (hr) image is 360x256 and the size of my low-resolution (lr) image is 45x32, and the lr image is upsampled by eight times with a bilinear interpolation. Can the values of h, w and m be set to 180, 180 and 64 respectively?

Looking forward to your reply, thanks again!

from pisr.

mdswyz avatar mdswyz commented on August 14, 2024

Figure_1

This figure shows the results of HR and LR in the previous comment. The red line is HR and the blue line is LR

from pisr.

wonkyunglee avatar wonkyunglee commented on August 14, 2024

I think m should be 16 (= 256 / 8 / 2, which has the same relationship with 200 / 2 / 2 of our case).

from pisr.

mdswyz avatar mdswyz commented on August 14, 2024

OK, I get it.
Thank you.

from pisr.

star-lunar avatar star-lunar commented on August 14, 2024

Hello!
Have you run the author's code?The author's code, it doesn't work
Have you made any changes to the author's code?

from pisr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.