Ejemplo n.º 1
0
                file_label='t10k-labels.idx1-ubyte')
    b.select_samples([para['class']])
    for ns in range(num_s):
        imgs_now = list()
        print('Processing the image ' + str(samples[nc][ns]) + ' in class ' +
              str(para['class']))
        for n in range(num_f):
            img0, img1, marked_img, order = get_marked_imgs(
                a, b, nums_features[n], samples[nc][ns], para, select_way)
            if n == 0:
                imgs_now.append(img0.copy())
                titles.append('Original img')
            if if_mark:
                imgs_now.append(marked_img.copy())
            else:
                imgs_now.append(img1.copy())
            # tmp = img1.reshape(-1, )
            # tmp[order[:nums_features[n]]] = 0
            # show_multiple_images_v1([tmp.reshape(img1.shape)])
            ssim = compare_ssim(img0, img1)
            title = 'N=' + str(nums_features[n]) + ', SSIM=' + str(ssim)
            titles.append(title)
        save_one_image(join_imgs_in_one_row(imgs_now), '0' + select_way)
        imgs = imgs + imgs_now.copy()

save_exp = str(classes) + '_' + dataset
show_multiple_images_v1(imgs,
                        lxy=(num_s_tot, num_f + 1),
                        titles=titles,
                        save_name=save_exp)
Ejemplo n.º 2
0
    para['chi'] = chi[nc]
    a, para = gtn_one_class(para)
    b = TNmachineLearning.MachineLearningFeatureMap(para['d'], para['dataset'])
    b.load_data(data_path=b.data_path,
                file_sample='t10k-images.idx3-ubyte',
                file_label='t10k-labels.idx1-ubyte')
    b.select_samples([para['class']])
    for ns in range(num_s):
        imgs_now = list()
        print('Processing the image ' + str(samples[ns]) + ' in class ' +
              str(para['class']))
        for n in range(num_f):
            img0, img1, marked_img, order = get_marked_imgs(
                a, b, nums_features[n], samples[ns], para, select_way)
            if n == 0 and nc == 0:
                original_imgs.append(img0.copy())
            if if_mark:
                imgs_now.append(marked_img.copy())
            else:
                imgs_now.append(img1.copy())
            ssim = compare_ssim(img0, img1)
            title = 'N=' + str(nums_features[n]) + ', SSIM=' + str(ssim)
            titles.append(title)
        # save_one_image(join_imgs_in_one_row(imgs_now), '0'+select_way)
        imgs = imgs + imgs_now.copy()

save_exp = str(chi) + '_' + dataset
show_multiple_images_v1(original_imgs + imgs,
                        lxy=(1, num_c + 1),
                        save_name=save_exp)
Ejemplo n.º 3
0
from library.BasicFunctions import show_multiple_images_v1
import numpy as np

x = np.random.rand(28, 28)
show_multiple_images_v1([x])