예제 #1
0
def plot_wpsnr(arg):
    """
    Weighted PSNR
    BD-PSNR
    """
    t, st = vars(arg)['filename'], vars(arg)['filename_diff']
    for f in st:
        vars(arg)['filename_diff']=f
        yuv = YCbCr(**vars(arg))

        psnr = [p[0] for p in yuv.psnr()]

        N = len(psnr[:-2])
        ind = np.arange(N)  # the x locations for the groups

        # To get a uniq identifier
        plt.plot(ind, psnr[:-2], 'o-',label=f[-8:-4])

        del yuv

    plt.legend()
    plt.title(create_title_string(t, st))
    plt.ylabel('weighted dB')
    plt.xlabel('frame')
    plt.grid(True)

    plt.show()
예제 #2
0
def plot_psnr(arg):
    """
    PSNR
    """
    t, st = vars(arg)['filename'], vars(arg)['filename_diff']
    for f in st:
        vars(arg)['filename_diff'] = f
        yuv = YCbCr(**vars(arg))

        psnr = [p[3] for p in yuv.psnr()]

        N = len(psnr[:-2])
        ind = np.arange(N)  # the x locations for the groups

        # To get a uniq identifier
        plt.plot(ind, psnr[:-2], 'o-', label=f[-10:-8])

        del yuv

    plt.legend()
    plt.title(create_title_string(t, st))
    plt.ylabel('weighted dB')
    plt.xlabel('frame')
    plt.grid(True)
    plt.show()
예제 #3
0
파일: verify.py 프로젝트: Venti-/yuv-tools
    def test_8(self):
        """
        psnr
        """
        a = YCbCr(width=352, height=288, filename='foreman_cif_frame_0.yuv',
                  yuv_format_in='YV12', filename_diff='foreman_cif_frame_1.yuv')

        ret = a.psnr().next()

        self.assertEqual(ret, [27.68336995961328, 43.025594686475237, 43.343456122199385, 29.383484998976837])
예제 #4
0
파일: verify.py 프로젝트: Venti-/yuv-tools
    def test_14(self):
        """
        psnr - nan
        """
        a = YCbCr(width=352, height=288, filename='foreman_cif_frame_0.yuv',
                  yuv_format_in='YV12', filename_diff='foreman_cif_frame_0.yuv')

        ret = a.psnr().next()

        self.assertTrue(math.isnan(ret[0]))
        self.assertTrue(math.isnan(ret[1]))
        self.assertTrue(math.isnan(ret[2]))
        self.assertTrue(math.isnan(ret[3]))
예제 #5
0
    def test_14(self):
        """
        psnr - nan
        """
        a = YCbCr(width=352,
                  height=288,
                  filename='foreman_cif_frame_0.yuv',
                  yuv_format_in='YV12',
                  filename_diff='foreman_cif_frame_0.yuv')

        ret = a.psnr().next()

        self.assertTrue(math.isnan(ret[0]))
        self.assertTrue(math.isnan(ret[1]))
        self.assertTrue(math.isnan(ret[2]))
        self.assertTrue(math.isnan(ret[3]))
예제 #6
0
    def test_8(self):
        """
        psnr
        """
        a = YCbCr(width=352,
                  height=288,
                  filename='foreman_cif_frame_0.yuv',
                  yuv_format_in='YV12',
                  filename_diff='foreman_cif_frame_1.yuv')

        ret = a.psnr().next()

        self.assertEqual(ret, [
            27.68336995961328, 43.025594686475237, 43.343456122199385,
            29.383484998976837
        ])
예제 #7
0
파일: visual.py 프로젝트: xingdf/yuv-tools
def plot_psnr(arg):
    """
    PSNR
    """
    yuv = YCbCr(**vars(arg))

    psnr = [p[0] for p in yuv.psnr()]

    N = len(psnr)
    ind = np.arange(N)  # the x locations for the groups

    plt.figure()
    plt.title(create_title_string(arg))
    plt.plot(ind, psnr, 'ro-')
    plt.ylabel('dB')
    plt.xlabel('frame')
    plt.grid(True)

    plt.show()
예제 #8
0
def plot_psnr_all(arg):
    """
    PSNR, all planes
    """
    yuv = YCbCr(**vars(arg))

    psnr = [p for p in yuv.psnr()]

    N = len(psnr)
    ind = np.arange(N)  # the x locations for the groups

    plt.figure()
    plt.title(create_title_string(arg))
    plt.plot(ind, [i[0] for i in psnr], 'ko-', label='Y')
    plt.plot(ind, [i[1] for i in psnr], 'bo-', label='Cb')
    plt.plot(ind, [i[2] for i in psnr], 'ro-', label='Cr')
    plt.plot(ind, [i[3] for i in psnr], 'mo-', label='Frame')
    plt.legend()
    plt.ylabel('dB')
    plt.xlabel('frame')
    plt.grid(True)

    plt.show()
예제 #9
0
def plot_psnr_all(arg):
    """
    PSNR, all planes
    """
    yuv = YCbCr(**vars(arg))

    psnr = [p for p in yuv.psnr()]

    N = len(psnr)
    ind = np.arange(N)  # the x locations for the groups

    plt.figure()
    plt.title(create_title_string(arg))
    plt.plot(ind, [i[0] for i in psnr], 'ko-', label='Y')
    plt.plot(ind, [i[1] for i in psnr], 'bo-', label='Cb')
    plt.plot(ind, [i[2] for i in psnr], 'ro-', label='Cr')
    plt.plot(ind, [i[3] for i in psnr], 'mo-', label='Frame')
    plt.legend()
    plt.ylabel('dB')
    plt.xlabel('frame')
    plt.grid(True)

    plt.show()
예제 #10
0
    def on_b_calc(self, event):
        """
        Calculate
        """
        f1 = self.t_load_f1.GetValue()
        f2 = self.t_load_f2.GetValue()
        a = self.algo.GetValue()
        f = self.yuv_format.GetValue()
        s = self.t_size.GetValue()

        w, h = s.split('x')

        # are all parameters ok?
        if not os.path.isfile(f1) or not os.path.isfile(f2):
            print 'faulty inputfiles'
            raise IOError

        if not a in self.algo_list:
            print 'faulty algorithm'
            raise KeyError

        if not f in self.yuv_format_list:
            print 'faulty format'
            raise KeyError

        if not w.isdigit() or not h.isdigit():
            print 'faulty size'
            raise TypeError

        y = YCbCr(width=int(w), height=int(h), filename=f1,
                  yuv_format_in=f, filename_diff=f2, num=20)

        if 'psnr' in a:
            psnr = [p for p in y.psnr()][:-2]
            if a != 'psnr-all':
                ind = np.arange(len(psnr))  # the x locations for the groups
                self.axes.clear()
                self.axes.plot(ind, [i[self.algo_map[a]] for i in psnr],
                               'o-', picker=5)

                self.axes.set_title(os.path.basename(f1) + ' ' + a)
                self.axes.set_ylabel('dB')
                self.axes.set_xlabel('frame')

                self.canvas.draw()

            elif a == 'psnr-all':
                ind = np.arange(len(psnr))  # the x locations for the groups
                self.axes.clear()
                self.axes.plot(ind, [i[0] for i in psnr], 'ko-', label='Y', picker=5)
                self.axes.plot(ind, [i[1] for i in psnr], 'bo-', label='Cb', picker=5)
                self.axes.plot(ind, [i[2] for i in psnr], 'ro-', label='Cr', picker=5)
                self.axes.plot(ind, [i[3] for i in psnr], 'mo-', label='BD', picker=5)

                self.axes.set_title(os.path.basename(f1) + ' ' + a)
                self.axes.legend()
                self.axes.set_ylabel('dB')
                self.axes.set_xlabel('frame')

                self.canvas.draw()

        elif 'ssim' in a:
            ssim = [s for s in y.ssim()][:-2]
            ind = np.arange(len(ssim))  # the x locations for the groups
            self.axes.clear()
            self.axes.plot(ind, ssim, 'o-', picker=5)

            self.axes.set_title(os.path.basename(f1) + ' ' + a)
            self.axes.set_ylabel('index')
            self.axes.set_xlabel('frame')

            self.canvas.draw()
        else:
            print '~tilt'
예제 #11
0
    fname1 = sys.argv[1]
    fname2 = sys.argv[2]
    w = int(sys.argv[3])
    h = int(sys.argv[4])
    if sys.argv[5] in FMT:
        fmt = sys.argv[5]
    else:
        usage(sys.argv[0])

    Y = YCbCr(width=w, height=h, filename=fname1,
              yuv_format_in=fmt, filename_diff=fname2)

    data1 = load_data(Y, fname1)
    data2 = load_data(Y, fname2)

    psnr = Y.psnr().next()[0]
    ssim = Y.ssim().next()

    # First subplot
    figure()
    frame1 = subplot(121)
    plt.imshow(data1, cmap=cm.gray, hold=True)
    frame1.axes.get_xaxis().set_visible(False)
    frame1.axes.get_yaxis().set_visible(False)
    title("PSNR = %f" % psnr)

    # Second subplot
    frame2 = subplot(122)
    plt.imshow(data2, cmap=cm.gray, hold=True)
    frame2.axes.get_xaxis().set_visible(False)
    frame2.axes.get_yaxis().set_visible(False)
예제 #12
0
    def on_b_calc(self, event):
        """
        Calculate
        """
        f1 = self.t_load_f1.GetValue()
        f2 = self.t_load_f2.GetValue()
        a = self.algo.GetValue()
        f = self.yuv_format.GetValue()
        s = self.t_size.GetValue()

        w, h = s.split('x')

        # are all parameters ok?
        if not os.path.isfile(f1) or not os.path.isfile(f2):
            print 'faulty inputfiles'
            raise IOError

        if not a in self.algo_list:
            print 'faulty algorithm'
            raise KeyError

        if not f in self.yuv_format_list:
            print 'faulty format'
            raise KeyError

        if not w.isdigit() or not h.isdigit():
            print 'faulty size'
            raise TypeError

        y = YCbCr(width=int(w),
                  height=int(h),
                  filename=f1,
                  yuv_format_in=f,
                  filename_diff=f2,
                  num=20)

        if 'psnr' in a:
            psnr = [p for p in y.psnr()][:-2]
            if a != 'psnr-all':
                ind = np.arange(len(psnr))  # the x locations for the groups
                self.axes.clear()
                self.axes.plot(ind, [i[self.algo_map[a]] for i in psnr],
                               'o-',
                               picker=5)

                self.axes.set_title(os.path.basename(f1) + ' ' + a)
                self.axes.set_ylabel('dB')
                self.axes.set_xlabel('frame')

                self.canvas.draw()

            elif a == 'psnr-all':
                ind = np.arange(len(psnr))  # the x locations for the groups
                self.axes.clear()
                self.axes.plot(ind, [i[0] for i in psnr],
                               'ko-',
                               label='Y',
                               picker=5)
                self.axes.plot(ind, [i[1] for i in psnr],
                               'bo-',
                               label='Cb',
                               picker=5)
                self.axes.plot(ind, [i[2] for i in psnr],
                               'ro-',
                               label='Cr',
                               picker=5)
                self.axes.plot(ind, [i[3] for i in psnr],
                               'mo-',
                               label='BD',
                               picker=5)

                self.axes.set_title(os.path.basename(f1) + ' ' + a)
                self.axes.legend()
                self.axes.set_ylabel('dB')
                self.axes.set_xlabel('frame')

                self.canvas.draw()

        elif 'ssim' in a:
            ssim = [s for s in y.ssim()][:-2]
            ind = np.arange(len(ssim))  # the x locations for the groups
            self.axes.clear()
            self.axes.plot(ind, ssim, 'o-', picker=5)

            self.axes.set_title(os.path.basename(f1) + ' ' + a)
            self.axes.set_ylabel('index')
            self.axes.set_xlabel('frame')

            self.canvas.draw()
        else:
            print '~tilt'
예제 #13
0
    h = int(sys.argv[4])
    if sys.argv[5] in FMT:
        fmt = sys.argv[5]
    else:
        usage(sys.argv[0])

    Y = YCbCr(width=w,
              height=h,
              filename=fname1,
              yuv_format_in=fmt,
              filename_diff=fname2)

    data1 = load_data(Y, fname1)
    data2 = load_data(Y, fname2)

    psnr = Y.psnr().next()[0]
    ssim = Y.ssim().next()

    # First subplot
    figure()
    frame1 = subplot(121)
    plt.imshow(data1, cmap=cm.gray, hold=True)
    frame1.axes.get_xaxis().set_visible(False)
    frame1.axes.get_yaxis().set_visible(False)
    title("PSNR = %f" % psnr)

    # Second subplot
    frame2 = subplot(122)
    plt.imshow(data2, cmap=cm.gray, hold=True)
    frame2.axes.get_xaxis().set_visible(False)
    frame2.axes.get_yaxis().set_visible(False)