yjsunnn / FBANet

Official implementation of ICCV2023 "Towards Real-World Burst Image Super-Resolution: Benchmark and Method"
MIT License
113 stars 7 forks source link

code for reproducing Fig. 7 in the paper #4

Closed jamesli1618 closed 11 months ago

jamesli1618 commented 12 months ago

Could you please provide the code for reproducing Fig. 7 in the paper? Thanks for your help!

yjsunnn commented 11 months ago

Of course. The figure 7 is the polar map comparison of images before and after alignment.

import numpy as np
import matplotlib.pyplot as plt
import flowpy
import os
import cmath

save_path = 'Manual_polar_map_flo_fix20'
if not os.path.exists(save_path):
    os.makedirs(save_path)

flo_path = '../pytorch-pwc-master/result/patch/LR_patch_arrow/baseframe/test_LR_flo'
test_LR_path = '../pytorch-pwc-master/result/patch/LR_patch_arrow/baseframe/test_LR'

colormap = ['#FF0000', '#00FF00', '#0000FF', '#00FFFF', '#FF00FF', '#FFFF00', '#000000', '#A2142F',
            '#0072BD', '#D95319', '#EDB120', '#7E2F8E', '#77AC30']

def draw_polar(LR_list):
    fig = plt.figure()
    for number in range(1, 14):
        flo_name = 'out_{}_{}.flo'.format(LR_list, number)
        flo = flowpy.flow_read(os.path.join(flo_path, flo_name))
        height, width, co = flo.shape

        x_plane = flo[:, :, 0].reshape(-1)
        y_plane = flo[:, :, 1].reshape(-1)

        length = len(x_plane)
        r_polar = []
        theta_polar = []
        for i in range(length):
            cor = complex(x_plane[i], y_plane[i])
            r, theta = cmath.polar(cor)
            r_polar.append(r)
            theta_polar.append(theta)

        ax = fig.add_subplot(111, projection='polar')

        ax.set_ylim(0, 20)
        ax.set_yticks(np.arange(0, 20, 1.0))

        c = ax.scatter(theta_polar, r_polar, c=colormap[number-1], s=1, cmap='hsv', alpha=0.75)

    save_name = '{}_polar_map.png'.format(LR_list)
    plt.savefig(os.path.join(save_path,save_name))
    plt.close('all')