Python matplotlib.cm 模块,Greys_r() 实例源码

我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用matplotlib.cm.Greys_r()

项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def plot_x_y_yhat(x, y, y_hat, xsz, ysz, binz=False):
    """Plot x, y and y_hat side by side."""
    plt.close("all")
    f = plt.figure(figsize=(15, 10.8), dpi=300)
    gs = gridspec.GridSpec(1, 3)
    if binz:
        y_hat = (y_hat > 0.5) * 1.
    ims = [x, y, y_hat]
    tils = [
        "x:" + str(xsz) + "x" + str(xsz),
        "y:" + str(ysz) + "x" + str(ysz),
        "yhat:" + str(ysz) + "x" + str(ysz)]
    for n, ti in zip([0, 1, 2], tils):
        f.add_subplot(gs[n])
        if n == 0:
            plt.imshow(ims[n], cmap=cm.Greys_r)
        else:
            plt.imshow(ims[n], cmap=cm.Greys_r)
        plt.title(ti)

    return f
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def plot_x_x_yhat(x, x_hat):
    """Plot x, y and y_hat side by side."""
    plt.close("all")
    f = plt.figure()  # figsize=(15, 10.8), dpi=300
    gs = gridspec.GridSpec(1, 2)
    ims = [x, x_hat]
    tils = [
        "xin:" + str(x.shape[0]) + "x" + str(x.shape[1]),
        "xout:" + str(x.shape[1]) + "x" + str(x_hat.shape[1])]
    for n, ti in zip([0, 1], tils):
        f.add_subplot(gs[n])
        plt.imshow(ims[n], cmap=cm.Greys_r)
        plt.title(ti)
        ax = f.gca()
        ax.set_axis_off()

    return f
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def debug_plot_over_img(self, img, x, y, bb_d, bb_gt):
        """Plot the landmarks over the image with the bbox."""
        plt.close("all")
        fig = plt.figure()  # , figsize=(15, 10.8), dpi=200
        ax = plt.Axes(fig, [0., 0., 1., 1.])
        ax.set_axis_off()
        ax.imshow(img, aspect="auto", cmap='Greys_r')
        ax.scatter(x, y, s=10, color='r')
        rect1 = patches.Rectangle(
            (bb_d[0], bb_d[1]), bb_d[2]-bb_d[0], bb_d[3]-bb_d[1],
            linewidth=1, edgecolor='r', facecolor='none')
        ax.add_patch(rect1)
        rect2 = patches.Rectangle(
            (bb_gt[0], bb_gt[1]), bb_gt[2]-bb_gt[0], bb_gt[3]-bb_gt[1],
            linewidth=1, edgecolor='b', facecolor='none')
        ax.add_patch(rect2)
        fig.add_axes(ax)

        return fig
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def debug_draw_set(self, path_f, fd_out):
        if not os.path.exists(fd_out):
            os.makedirs(fd_out)
        with open(path_f, 'r') as f:
            stuff = pkl.load(f)
        for el in stuff:
            img_name = el["img_name"]
            print img_name
            img_gray = el["img_gray"]
            bb_d = el["bb_detector"]
            bb_gt = el["bb_ground_truth"]
            x = el["annox"]
            y = el["annoy"]
            fig = self.debug_plot_over_img(img_gray, x, y, bb_d, bb_gt)
            fig.savefig(
                fd_out+"/"+img_name, bbox_inches='tight', pad_inches=0,
                frameon=False, cmap=cm.Greys_r)
            del fig
项目:learning-class-invariant-features    作者:sbelharbi    | 项目源码 | 文件源码
def plot_x_y_yhat(x, y, y_hat, xsz, ysz, binz=False):
    """Plot x, y and y_hat side by side."""
    plt.close("all")
    f = plt.figure(figsize=(15, 10.8), dpi=300)
    gs = gridspec.GridSpec(1, 3)
    if binz:
        y_hat = (y_hat > 0.5) * 1.
    ims = [x, y, y_hat]
    tils = [
        "x:" + str(xsz) + "x" + str(xsz),
        "y:" + str(ysz) + "x" + str(ysz),
        "yhat:" + str(ysz) + "x" + str(ysz)]
    for n, ti in zip([0, 1, 2], tils):
        f.add_subplot(gs[n])
        if n == 0:
            plt.imshow(ims[n], cmap=cm.Greys_r)
        else:
            plt.imshow(ims[n], cmap=cm.Greys_r)
        plt.title(ti)

    return f
项目:LifelongVAE    作者:jramapuram    | 项目源码 | 文件源码
def _write_images(x_sample, x_reconstruct, vae_name, filename,
                  num_print=5, sup_title=None):
    fig = plt.figure(figsize=(8, 12))
    if sup_title:
        fig.suptitle(sup_title)

    for i in range(num_print):
        if x_sample is not None:
            plt.subplot(num_print, 2, 2*i + 1)
            #plt.imshow(x_sample[i].reshape(32, 32, 3))#, vmin=0, vmax=1)
            plt.imshow(x_sample[i].reshape(28, 28), cmap='Greys')#, vmin=0, vmax=1)
            plt.title("Test input")
            plt.colorbar()

        plt.subplot(num_print, 2, 2*i + 2)
        # plt.imshow(x_reconstruct[i].reshape(32, 32, 3))#, vmin=0, vmax=1)
        plt.imshow(x_reconstruct[i].reshape(28, 28), cmap='Greys')#, vmin=0, vmax=1)
        plt.title("Reconstruction")
        plt.colorbar()

    plt.savefig(filename, bbox_inches='tight', cmap=cm.Greys_r)
    plt.close()
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def show_landmarks_unit_test(self, im, phis_pred, phis_mean_train, bbox, save=False, path="../im.png"):
        """ Display a shape over the face image. (python)


        phis_pred: predicted phis [xxxyyy]
        phis_mean_train: mean phis of ground of truth
        bbox=[x y w h]
        im = np.ndarray
        """
        plt.close('all')
        if save:
            plt.ioff()

        nfids = int(len(phis_pred)/2)
        plt.imshow(im, cmap = cm.Greys_r)
        gt = plt.scatter(x=phis_mean_train[0:nfids], y=phis_mean_train[nfids:], c='g', s=40)
        pr = plt.scatter(x=phis_pred[0:nfids], y=phis_pred[nfids:], c='r', s=20)

        mse = np.mean(np.power((phis_pred - phis_mean_train), 2))
        plt.legend((gt, pr), ("mean shape train", "prediction, MSE="+str(mse)), scatterpoints=1,loc='lower left', fontsize=8, fancybox=True, shadow=True)
        """
        plt.plot([bbox[0], bbox[0]],[bbox[1],bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0], bbox[0]+bbox[2]],[bbox[1], bbox[1]],'-b', linewidth=1)
        plt.plot([bbox[0]+bbox[2], bbox[0]+bbox[2]],[bbox[1], bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0] ,bbox[0]+bbox[2]],[bbox[1]+bbox[3] ,bbox[1]+bbox[3]],'-b', linewidth=1)
        """
        plt.axis('off')

        if save:
            plt.savefig(path,bbox_inches='tight', dpi=1000)
            plt.ion()
        else:
            plt.show()
            raw_input("... Press ENTER to continue,")

        plt.close('all')
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def show_only_landmarks_unit_test(self, im, phis_pred, bbox, save=False, path="../im.png"):
        """ Display a shape over the face image. (python)


        phis_pred: predicted phis [xxxyyy]
        phis_mean_train: mean phis of ground of truth
        bbox=[x y w h]
        im = np.ndarray
        """
        plt.close('all')
        if save:
            plt.ioff()

        nfids = int(len(phis_pred)/2)
        plt.imshow(im, cmap = cm.Greys_r)
        pr = plt.scatter(x=phis_pred[0:nfids], y=phis_pred[nfids:], c='w', s=20)

        plt.legend([pr], ["prediction"], scatterpoints=1,loc='lower left', fontsize=8, fancybox=True, shadow=True)
        """
        plt.plot([bbox[0], bbox[0]],[bbox[1],bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0], bbox[0]+bbox[2]],[bbox[1], bbox[1]],'-b', linewidth=1)
        plt.plot([bbox[0]+bbox[2], bbox[0]+bbox[2]],[bbox[1], bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0] ,bbox[0]+bbox[2]],[bbox[1]+bbox[3] ,bbox[1]+bbox[3]],'-b', linewidth=1)
        """
        plt.axis('off')

        if save:
            plt.savefig(path,bbox_inches='tight', dpi=100)
            plt.ion()
        else:
            plt.show()
            raw_input("... Press ENTER to continue,")

        plt.close('all')
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def plot_code_recont_for_one_set(self, data, in_aes_path):
        """Plot x-code-x_hat for one set.
        """
        x = data['x']
        code = data['code']
        reconst = data['reconstruction']
        nbr = 10 # plot only 100 samples ... just to see.
        for i in xrange(nbr):
            # x
            xx = x[i]
            sz_x = xx.shape[0]
            sqrt_sz_x = int (np.sqrt(sz_x))
            xx = np.resize(xx, sqrt_sz_x ** 2).reshape(sqrt_sz_x, sqrt_sz_x)
            # code
            c = code[i]
            sz_c = c.shape[0]
            sqrt_sz_c = int (np.sqrt(sz_c))
            c = np.resize(c, sqrt_sz_c ** 2).reshape(sqrt_sz_c, sqrt_sz_c)

            # reconstruction
            recon = reconst[i]
            sz_recon= recon.shape[0]
            sqrt_sz_recon = int (np.sqrt(sz_recon))
            recon = np.resize(recon, sqrt_sz_recon ** 2).reshape(sqrt_sz_recon, sqrt_sz_recon)
            # plotting ..
            fig, axs = plt.subplots(3)  
            fig.tight_layout()
            xx_ax = axs[0].imshow(xx, cmap = cm.Greys_r)
            axs[0].set_title('x')
            fig.colorbar(xx_ax, ax=axs[0])
            c_ax = axs[1].imshow(c)
            axs[1].set_title('code')
            c_ax.set_cmap('spectral')
            fig.colorbar(c_ax, ax=axs[1])
            recon_ax = axs[2].imshow(recon, cmap = cm.Greys_r)
            axs[2].set_title('x_hat')
            fig.colorbar(recon_ax, ax=axs[2])
            fig.savefig(in_aes_path+str(i)+".png",bbox_inches='tight')
            plt.close("all")
项目:recognizeFitExercise    作者:tyiannak    | 项目源码 | 文件源码
def getLBP(img):
    img2 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    radius = 1
    n_points = 8 * radius
    lbpImage = (local_binary_pattern(img2, n_points, radius)).astype(int)**(1.0/radius)

    # block processing:
    lbpImages = block_view(lbpImage, ( int(lbpImage.shape[0] / 2), int(lbpImage.shape[1] / 4)))


    count = 0

    LBP = np.array([]); 
    for i in range(lbpImages.shape[0]):         # for each block:
        for j in range(lbpImages.shape[1]):
            count += 1
#           plt.subplot(4,2,count)
#           plt.imshow(lbpImages[i,j,:,:],cmap = cm.Greys_r)
#           plt.subplot(4,2,count+4*2/2)
#           print count*2+1
            LBPt = cv2.calcHist([lbpImages[i,j,:,:].astype('uint8')], [0], None, [8], [0, 256]) 
            LBP = np.append(LBP, LBPt[:,0]);
#           plt.plot(LBPt)
#   plt.show()


    Fnames = ["LBP"+str(i).zfill(2) for i in range(len(LBP))]

    return normalize(LBP).tolist(), Fnames
项目:text-renderer    作者:cjnolet    | 项目源码 | 文件源码
def get_bordershadow(self, bg_arr, colour):
        """
        Gets a border/shadow with the movement state [top, right, bottom, left].
        Inset or outset is random.
        """
        bs = self.borderstate.get_sample()
        outset = bs['outset']
        width = bs['width']
        position = bs['position']

        # make a copy
        border_arr = bg_arr.copy()
        # re-colour
        border_arr[...,0] = colour
        if outset:
            # dilate black (erode white)
            border_arr[...,1] = ndimage.grey_dilation(border_arr[...,1], size=(width, width))
            border_arr = self.arr_scroll(border_arr, position[0], position[1])

            # canvas = 255*n.ones(bg_arr.shape)
            # canvas = grey_blit(border_arr, canvas)
            # canvas = grey_blit(bg_arr, canvas)
            # pyplot.imshow(canvas[...,0], cmap=cm.Greys_r)
            # pyplot.show()

            return border_arr, bg_arr
        else:
            # erode black (dilate white)
            border_arr[...,1] = ndimage.grey_erosion(border_arr[...,1], size=(width, width))
            return bg_arr, border_arr
项目:text-renderer    作者:cjnolet    | 项目源码 | 文件源码
def add_fillimage(self, arr):
        """
        Adds a fill image to the array.
        For blending this might be useful:
        - http://stackoverflow.com/questions/601776/what-do-the-blend-modes-in-pygame-mean
        - http://stackoverflow.com/questions/5605174/python-pil-function-to-divide-blend-two-images
        """
        fis = self.fillimstate.get_sample(arr)

        image = fis['image']
        blend_mode = fis['blend_mode']
        blend_amount = fis['blend_amount']
        blend_order = fis['blend_order']

        # change alpha of the image
        if blend_amount > 0:
            if blend_order:
                image[...,1] *= blend_amount
                arr = grey_blit(image, arr, blend_mode=blend_mode)
            else:
                arr[...,1] *= (1 - blend_amount)
                arr = grey_blit(arr, image, blend_mode=blend_mode)

        # pyplot.imshow(image[...,0], cmap=cm.Greys_r)
        # pyplot.show()

        return arr
项目:pyImageClassification    作者:tyiannak    | 项目源码 | 文件源码
def getLBP(img):
    img2 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    radius = 1
    n_points = 8 * radius
    lbpImage = (local_binary_pattern(img2, n_points, radius)).astype(int)**(1.0/radius)

    # block processing:
    lbpImages = block_view(lbpImage, ( int(lbpImage.shape[0] / 2), int(lbpImage.shape[1] / 4)))


    count = 0

    LBP = np.array([]); 
    for i in range(lbpImages.shape[0]):         # for each block:
        for j in range(lbpImages.shape[1]):
            count += 1
#           plt.subplot(4,2,count)
#           plt.imshow(lbpImages[i,j,:,:],cmap = cm.Greys_r)
#           plt.subplot(4,2,count+4*2/2)
#           print count*2+1
            LBPt = cv2.calcHist([lbpImages[i,j,:,:].astype('uint8')], [0], None, [8], [0, 256]) 
            LBP = np.append(LBP, LBPt[:,0]);
#           plt.plot(LBPt)
#   plt.show()


    Fnames = ["LBP"+str(i).zfill(2) for i in range(len(LBP))]

    return normalize(LBP).tolist(), Fnames
项目:Jackal_Velodyne_Duke    作者:MengGuo    | 项目源码 | 文件源码
def visualize_jackal(figure, pose, img):
    pyplot.cla()
    fig = figure
    ax = fig.add_subplot(111)
    ax.imshow(img, cmap=cm.Greys_r)
    ax.axis('image')
    if pose:
        meter_to_pixel = 10.6
        xl = pose[0]*meter_to_pixel
        yl = pose[1]*meter_to_pixel
        dl = pose[2]
        ax.plot(xl, yl, 'ro', markersize=10)
        L1 = 0.8*meter_to_pixel
        L2 = 1.6*meter_to_pixel
        car=[(xl-L1,yl-L1), (xl-L1,yl+ L1), (xl, yl+L2), (xl+L1, yl+L1), (xl+L1,yl-L1)]
        polygon2 = Polygon(transform(car, [xl,yl],dl+3.14), fill = True, facecolor='blue', edgecolor='blue', lw=4, zorder=2)
        ax.add_patch(polygon2)    
    ax.grid()
    #fig.subplots_adjust(0.003,0.062,0.97,0.94)
    #pyplot.show()
    pyplot.pause(0.01)
    return fig


#==============================
#==============================
项目:ActiveBoundary    作者:MiriamHu    | 项目源码 | 文件源码
def generate_images_line_save(self, line_segment, query_id, image_original_space=None):
        """
        ID of query point from which query line was generated is
        added to the filename of the saved line query.
        :param line_segment:
        :param query_id:
        :return:
        """
        try:
            if image_original_space is not None:
                x = self.generative_model.decode(image_original_space.T)
            else:
                x = self.generative_model.decode(to_vector(self.dataset.data["features"][
                                                               query_id]).T)  # comes from dataset.data["features"], so is already in original space in which ALI operates.
            save_path = os.path.join(self.save_path_queries, "pointquery_%d_%d.png" % (self.n_queries + 1, query_id))
            if x.shape[1] == 1:
                plt.imsave(save_path, x[0, 0, :, :], cmap=cm.Greys)
            else:
                plt.imsave(save_path, x[0, :, :, :].transpose(1, 2, 0), cmap=cm.Greys_r)

            decoded_images = self.generative_model.decode(self.dataset.scaling_transformation.inverse_transform(
                line_segment))  # Transform to original space, in which ALI operates.
            figure = plt.figure()
            grid = ImageGrid(figure, 111, (1, decoded_images.shape[0]), axes_pad=0.1)
            for image, axis in zip(decoded_images, grid):
                if image.shape[0] == 1:
                    axis.imshow(image[0, :, :].squeeze(),
                                cmap=cm.Greys, interpolation='nearest')
                else:
                    axis.imshow(image.transpose(1, 2, 0).squeeze(),
                                cmap=cm.Greys_r, interpolation='nearest')
                axis.set_yticklabels(['' for _ in range(image.shape[1])])
                axis.set_xticklabels(['' for _ in range(image.shape[2])])
                axis.axis('off')
            save_path = os.path.join(self.save_path_queries, "linequery_%d_%d.pdf" % (self.n_queries + 1, query_id))
            plt.savefig(save_path, transparent=True, bbox_inches='tight')
        except Exception as e:
            print "EXCEPTION:", traceback.format_exc()
            raise e
项目:SRN    作者:KevinKecc    | 项目源码 | 文件源码
def plot_single_scale(scale_lst, size):
    pylab.rcParams['figure.figsize'] = size, size/2

    plt.figure()
    for i in range(0, len(scale_lst)):
        s=plt.subplot(1,5,i+1)
        plt.imshow(1-scale_lst[i], cmap = cm.Greys_r)
        #plt.imshow(1-scale_lst[i])
        s.set_xticklabels([])
        s.set_yticklabels([])
        s.yaxis.set_ticks_position('none')
        s.xaxis.set_ticks_position('none')
    plt.tight_layout()
项目:csdm    作者:moliusimon    | 项目源码 | 文件源码
def plot_image(image, shape, shape_gt):
    implot = plt.imshow(image, cmap=cm.Greys_r)
    plt.scatter(shape_gt[:, 1], shape_gt[:, 0], color='blue')
    plt.scatter(shape[:, 1], shape[:, 0], color='green')
    plt.show()
项目:500LineorLess_CN    作者:HT524    | 项目源码 | 文件源码
def _draw(self, sample):
        pixelArray = [sample[j:j+self.WIDTH_IN_PIXELS] for j in xrange(0, len(sample), self.WIDTH_IN_PIXELS)]
        plt.imshow(zip(*pixelArray), cmap = cm.Greys_r, interpolation="nearest")
        plt.show()
项目:structured-output-ae    作者:sbelharbi    | 项目源码 | 文件源码
def show_landmarks_points(self, im, phis_pred, phis_gt, bbox, nrmse=-1 ,save=False, path="../im.png"):
        """ Display a shape over the face image. (python)


        phis_pred: predicted phis [xxxyyy]
        phis_gt: phis of ground of truth
        bbox=[x y w h]
        im = np.ndarray
        nrmse: float (nrmse between gt and pred)
        """
        plt.close('all')
        if save:
            plt.ioff()

        nfids = int(len(phis_pred)/2)
        plt.imshow(im, cmap = cm.Greys_r)


        if nrmse > 0:
            gt = plt.scatter(x=phis_gt[0:nfids], y=phis_gt[nfids:], c='g', s=40)
            pr = plt.scatter(x=phis_pred[0:nfids], y=phis_pred[nfids:], c='r', s=20)
            plt.legend((gt, pr), ("grund truth", "prediction, nrmse="+str(nrmse)), scatterpoints=1, fontsize=8, bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
                       ncol=2, mode="expand", borderaxespad=0., fancybox=True, shadow=True)
        else:       # just display the landmarks of an image.   gt=pred

            gt = plt.scatter(x=phis_gt[0:nfids], y=phis_gt[nfids:], c='g', s=20)
            plt.legend([gt], ["landmarks"], scatterpoints=1, fontsize=8, bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
                       ncol=1, mode="expand", borderaxespad=0., fancybox=True, shadow=True)
        """
        plt.plot([bbox[0], bbox[0]],[bbox[1],bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0], bbox[0]+bbox[2]],[bbox[1], bbox[1]],'-b', linewidth=1)
        plt.plot([bbox[0]+bbox[2], bbox[0]+bbox[2]],[bbox[1], bbox[1]+bbox[3]],'-b', linewidth=1)
        plt.plot([bbox[0] ,bbox[0]+bbox[2]],[bbox[1]+bbox[3] ,bbox[1]+bbox[3]],'-b', linewidth=1)
        """
        plt.axis('off')

        if save:
            plt.savefig(path,bbox_inches='tight', dpi=100)
            plt.ion()
        else:
            plt.show()
            raw_input("... Press ENTER to continue,")

        plt.close('all')
项目:pythonprograms    作者:ElsaMJohnson    | 项目源码 | 文件源码
def subgrids(file, res=25, cut=1, blim=23, rlim=22,overlap = 'No',outfile='out.txt'):
#  galfile='m101output24nol.txt'
#res=24.
   if (overlap == 'Yes'):
    area = 4*res*res
   elif (overlap == 'No'):
    area = res*res
   sbfactor = 2.5*np.log10(area)
   xx,yy,bm,rm,ber,rer = np.genfromtxt(file,dtype = float, skiprows=1,unpack=True)
   Xn=np.divide(np.subtract(xx,min(xx)),res) +1.
   Yn=np.divide(np.subtract(yy,min(yy)),res) +1
   mX=max(Xn)
   mY=max(Yn)
   xlen = len(Xn)
   ylen = len(Yn)
   br=[]
   color = []
   Z = []
   b = bm+sbfactor
   r = rm+sbfactor
   br=np.subtract(b,r)
#Thinking about the cut off. If red is really red b/c blue is really faint
# Need to change this as per resolution:
# for 30 res (15, this was 23.1 and 22 resp)
   for i in range(len(br)):
         if br[i]<=cut:
                if b[i]>=blim:
                        color.append('g')
                        Z.append(0.)
                elif b[i]<blim:
                        color.append('b')
                        Z.append(abs(round(b[i],1)-blim))
         elif br[i]>cut:
                if r[i]>=rlim:
                        color.append('g')
                        Z.append(0.)
                elif r[i]<rlim:
                        color.append('r')
                        Z.append(abs(round(r[i],1)-rlim))

#if you want to save to a text file at this point:
   np.savetxt(outfile,np.column_stack((Xn,Yn,Z)),fmt=('%5.2f','%5.2f','%10.5f'))
   Z = np.array(Z).reshape(mX,mY)
   plt.figure()
   #Below is for color
   #imshow(Z)
   #This is for grayscale
   plt.imshow(Z,cmap = cm.Greys_r)
   return Z,Xn,Yn,color

##Heat filter to get rid of stars
##First all of the special subroutines
项目:DeepVis-PredDiff    作者:lmzintgraf    | 项目源码 | 文件源码
def plot_results(x_test, x_test_im, sensMap, predDiff, tarFunc, classnames, testIdx, save_path):
    '''
    Plot the results of the relevance estimation
    '''
    imsize = x_test.shape  

    tarIdx = np.argmax(tarFunc(x_test)[-1])
    tarClass = classnames[tarIdx]
    #tarIdx = 287

    plt.figure()
    plt.subplot(2,2,1)
    plt.imshow(x_test_im, interpolation='nearest')
    plt.title('original')
    frame = pylab.gca()
    frame.axes.get_xaxis().set_ticks([])
    frame.axes.get_yaxis().set_ticks([]) 
    plt.subplot(2,2,2)
    plt.imshow(sensMap, cmap=cm.Greys_r, interpolation='nearest')
    plt.title('sensitivity map')
    frame = pylab.gca()
    frame.axes.get_xaxis().set_ticks([])
    frame.axes.get_yaxis().set_ticks([]) 
    plt.subplot(2,2,3)
    p = predDiff.reshape((imsize[1],imsize[2],-1))[:,:,tarIdx]
    plt.imshow(p, cmap=cm.seismic, vmin=-np.max(np.abs(p)), vmax=np.max(np.abs(p)), interpolation='nearest')
    plt.colorbar()
    #plt.imshow(np.abs(p), cmap=cm.Greys_r)
    plt.title('weight of evidence')
    frame = pylab.gca()
    frame.axes.get_xaxis().set_ticks([])
    frame.axes.get_yaxis().set_ticks([]) 
    plt.subplot(2,2,4)
    plt.title('class: {}'.format(tarClass))
    p = get_overlayed_image(x_test_im, p)
    #p = predDiff[0,:,:,np.argmax(netPred(net, x_test)[0]),1].reshape((224,224))
    plt.imshow(p, cmap=cm.seismic, vmin=-np.max(np.abs(p)), vmax=np.max(np.abs(p)), interpolation='nearest')
    #plt.title('class entropy')
    frame = pylab.gca()
    frame.axes.get_xaxis().set_ticks([])
    frame.axes.get_yaxis().set_ticks([]) 

    fig = plt.gcf()
    fig.set_size_inches(np.array([12,12]), forward=True)
    plt.tight_layout()
    plt.tight_layout()
    plt.tight_layout()
    plt.savefig(save_path)
    plt.close()