예제 #1
0
    def start_btn_cb(self):
        if self.errors():
            exit()

        img_h = int(self.img_h.get())
        img_w = int(self.img_w.get())
        tile_val = int(self.tile_size.get())
        dis_metric = self.hist_var.get()
        filename = self.image_path[self.image_path.rfind("/") + 1:-4]
        filename_out = filename + time.strftime("%Y%m%d-%H-%M-%S") + \
                       "-" + dis_metric + "-" + str(tile_val) + "-" + \
                       str(img_w) + "x" + str(img_h)

        mos = Mosaic(self.image_path, (img_w, img_h), tile_val,
                     dis_metric, filename_out)

        if self.part_chooser.get() == "A":
            if self.src_dir is None:
                print("Select source directory")
                exit()
            mos.read_src_images(self.src_dir)
            mos.create_mosaic(self.src_dir)
        elif self.part_chooser.get() == "C":
            dir = mos.classify_img()
            mos.read_src_images(dir)
            mos.create_mosaic(dir)
예제 #2
0
    def start(self):
        self.msc = Mosaic()
        self.msc.im = self.img_file
        self.msc.path = self.path
        self.msc.grid = self.get_grid()

        self.progressBar.show()

        self.new_image = self.msc.make_mosaic(self.progressBar)
        self.mozaika.setPixmap(QtGui.QPixmap('temporary_img.jpg'))
        os.remove('temporary_img.jpg')

        self.action_save_img.setEnabled(True)
예제 #3
0
def main():
    if len(sys.argv) != 3:
        print("No input file!")
        return -1
    path = sys.argv[1]

    if not os.path.isfile(path):
        print("File '" + path + "' does not exist!")
        return -1
    
    oim = Image.open(path)
    oimage = np.array(oim, dtype=np.uint8)

    im = oim.resize((int(oim.width/2), int(oim.height/2)), Image.BICUBIC)
    image = np.array(im, dtype=np.uint8)

    mos = Mosaic(image, im.width, im.height)
    mimage = mos.Algorithm()

    epi = MEPR(mimage, 2)
    out = epi.Algorithm()

    #plt.imshow(out, cmap='gray', vmin=0, vmax=255)

    #mos = MGBI_5(out)
    #out = mos.Algorithm()

    #out[:3, :, :] = oimage[:3, :, :]
    #out[:, :3, :] = oimage[:, :3, :]
    #out[-3:, :, :] = oimage[-3:, :, :]
    #out[:, -3:, :] = oimage[:, -3:, :]

    plt.imshow(out[...,1], cmap='gray', vmin=0, vmax=255)
    #plt.imshow(out)
    plt.show()

    im = Image.fromarray(out)
    filename, ext = os.path.splitext(path)
    im.save("result/" + os.path.basename(filename) + "_2x" + ext)

    p = do_psnr(read_img(oimage), read_img(out))
    print(p)
    #im.save("result/kodim01.png")
    f = open("demofile2.txt", "a")
    f.write(os.path.basename(filename) + ": " + str(p) + "\n")
    f.close()
예제 #4
0
    def start_btn_cb(self):
        if self.errors():
            exit()

        img_h = int(self.img_h.get())
        img_w = int(self.img_w.get())
        tile_val = int(self.tile_size.get())
        dis_metric = self.hist_var.get()
        filename = self.image_path[self.image_path.rfind("/") + 1:-4]
        filename_out = filename + time.strftime(
            "%Y%m%d-%H-%M-%S") + "-" + dis_metric + "-" + str(
                tile_val) + "-" + str(img_w) + "x" + str(img_h)
        mos = Mosaic(self.image_path, (img_w, img_h), tile_val, self.src_dir,
                     dis_metric, filename_out)
        if self.part_chooser.get() == "A":
            mos.read_src_images()
            mos.create_mosaic()
        elif self.part_chooser.get() == "C":
            mos.compute_partB()
            mos.update_src_images()
            mos.read_src_images()
            mos.create_mosaic()
예제 #5
0
 def _ee_image(self):
     logging.info('Creating mosaic of ' + str(self))
     return Mosaic(self).create(self._data_sets())
예제 #6
0
from mosaic import Mosaic

testSubject = Mosaic()

RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)


# In           Out
# RRGGBB  ==>  RR GG BB
# RRGGBB       RR GG BB
def test_tile_6_by_2_as_2_by_2():
    pixels = [[RED, RED], [RED, RED], [GREEN, GREEN], [GREEN, GREEN],
              [BLUE, BLUE], [BLUE, BLUE]]
    mosaic = testSubject.tile(pixels, (2, 2))
    assert len(mosaic) == 3
    assert len(mosaic[0]) == 1
    assert len(mosaic[1]) == 1
    assert len(mosaic[2]) == 1
    for x in range(0, 3):
        for y in range(0, 1):
            assert len(mosaic[x][y]) == 2
            for i in range(0, 2):
                assert len(mosaic[x][y][i]) == 2
                for j in range(0, 2):
                    if x == 0:
                        color = RED
                    elif x == 1:
                        color = GREEN
                    else:
예제 #7
0
path1 = "/Users/liumeiyu/Downloads/IMG_7575.JPG"
path2 = "/Users/liumeiyu/Downloads/test1.jpg"
path3 = "/Users/liumeiyu/Downloads/test2.jpg"

A = Histogram(path1)
B = Smooth(path1)
C = Change(path1)
D = Base(path1)
E = Binary(path1)
F = D_E(path1)
G = Warp(path1)
H = Cvt(path1)
K = Edge_detection(path1)
L = Segmentation(path1)
M = Mosaic(path3)
N = Sampling(path1)
P = Fusion(path1)

# A.img_histogram_trans()
# A.img_histogram()

# B.linear_smooth_np()
# B.linear_smooth()
# B.box_smooth()
# B.gaussian_smooth()
# B.median_smooth()
# B.median_smooth_x(5)

# C.fft_high_change(60)
# C.change_cv()
예제 #8
0
arg_parser.add_argument('-y',
                        dest='y',
                        type=int,
                        help='Mosaic thumbnail tile Y dimension')
arg_parser.add_argument('-o',
                        dest='output_file',
                        type=str,
                        required=True,
                        help='Mosaic output image name')

args = arg_parser.parse_args()

# mosaic creation constructs
dimensions = (args.x or args.thumb_size, args.y or args.thumb_size)
image_mapper = ImageMapper()
mosaic_builder = Mosaic()
pixel_analyzer = PixelAnalyzer()
image_retriever = ImageRetrievalFactory.construct(args.source_type, dimensions,
                                                  args.input_file)
image_library = ImageLibrary()

print("Parsing source image...")
mosaic = mosaic_builder.tile(image_mapper.read_pixels(args.input_file),
                             dimensions)

if args.source_type == ImageRetrievalFactory.RETRIEVE_LIBRARY:
    print("Loading image library...")
    image_retriever.load_library(image_library)

print("Generating photomosaic...")
for i in range(0, len(mosaic)):