@@ -0,0 +1,2451 @@
+import numpy as np%0Aimport matplotlib.pyplot as plt%0Aimport matplotlib%0A%0A%0Aclass PatchLabeling:%0A    def __init__(self):%0A        self.shift_is_held = False%0A        self.patchdata = None%0A        self.image_canvas = None%0A        self.fullscreen = False%0A        self.window_idx = 0%0A        self.labels = None%0A        self.patches = %5B%5D%0A        self.selected = %5B%5D%0A        self.invalid = %5B%5D%0A        self.invalid_selected = %5B%5D%0A        self.show_size = (10, 10)  # width, height%0A        self.patch_size = (24, 24)  # width, height%0A%0A    def key_pressed(self, event):%0A        if event.key == 'a' or event.key == 'd':%0A            idx_step = self.show_size%5B0%5D * self.show_size%5B1%5D%0A%0A            if event.key == 'a':%0A                if self.window_idx %3E 0:%0A                    self.window_idx -= idx_step%0A            elif event.key == 'd':%0A                self.window_idx += idx_step%0A            self.show_patches()%0A        elif event.key == 'escape' or event.key == 'q':%0A            exit(0)%0A%0A    def show_patches(self):%0A        image = np.zeros(((self.patch_size%5B1%5D + 1) * self.show_size%5B1%5D,%0A                          (self.patch_size%5B0%5D + 1) * self.show_size%5B0%5D))%0A%0A        for i in range(self.show_size%5B0%5D * self.show_size%5B1%5D):%0A            if self.window_idx + i + 1 %3E 120:%0A                break%0A%0A            a = np.random.rand(self.patch_size%5B0%5D, self.patch_size%5B1%5D)%0A%0A            y = i // self.show_size%5B0%5D%0A            x = i %25 self.show_size%5B0%5D%0A            image%5By * (self.patch_size%5B1%5D + 1):y * (self.patch_size%5B1%5D + 1) + self.patch_size%5B1%5D,%0A            x * (self.patch_size%5B0%5D + 1):x * (self.patch_size%5B0%5D + 1) + self.patch_size%5B0%5D%5D = a%0A%0A        if self.image_canvas is None:%0A            self.image_canvas = fig.gca().imshow(image, cmap=plt.get_cmap('gray'),%0A                                                 interpolation='nearest')%0A        else:%0A            self.image_canvas.set_data(image)%0A%0A        fig.suptitle(str(self.window_idx) + ' - ' + str(%0A            self.window_idx + self.show_size%5B0%5D * self.show_size%5B1%5D) + ' / ' + str(%0A            120), fontsize=20)%0A        fig.canvas.draw()%0A%0A%0Aif __name__ == %22__main__%22:%0A    fig = plt.figure()%0A    bla = PatchLabeling()%0A%0A    bla.show_patches()%0A    plt.connect(%22key_press_event%22, bla.key_pressed)%0A%0A    if matplotlib.get_backend() == 'Qt4Agg':%0A        f_manager = plt.get_current_fig_manager()%0A        f_manager.window.move(0, 0)%0A        if bla.fullscreen:%0A            f_manager.window.showMaximized()%0A%0A    plt.show()%0A

work on tool for showing images from datasets