Ejemplo n.º 1
0
 def data(self):
     size = (self.rows, self.cols)
     texture_dict = dict()
     array_index = [[0 for j in range(self.cols)] for i in range(self.rows)]
     texture_arrays = []
     current_index = 0
     for i in range(self.rows):
         for j in range(self.cols):
             t = self.__cells[i][j].texture
             if t not in texture_dict:
                 texture_dict[t] = current_index
                 texture_arrays.append(np.get_array_from_texture(t))
                 current_index += 1
             array_index[i][j] = texture_dict[t]
     print(current_index)
     return (size, texture_arrays, array_index)
Ejemplo n.º 2
0
 def data(self):
     size = (self.rows, self.cols)
     texture_dict = dict()
     array_index = [[0 for j in range(self.cols)] for i in range(self.rows)]
     texture_arrays = []  # stores the actual pixel data
     current_index = 0
     # we should add tag and layer data too!
     for i in range(self.rows):
         for j in range(self.cols):
             cell = self.__cells[i][j]
             t = cell.texture
             if t not in texture_dict:
                 texture_dict[t] = current_index
                 texture_arrays.append(np.get_array_from_texture(t))
                 current_index += 1
             array_index[i][j] = texture_dict[t]
     print(current_index)
     return (size, self.__cells[0][0].scale, texture_arrays, array_index)
Ejemplo n.º 3
0
    def data(self):
        size = (self.rows, self.cols)
        texture_dict: Dict[Texture, int] = dict()
        array_index = [[0 for j in range(self.cols)] for i in range(self.rows)]
        tags = [[[] for j in range(self.cols)] for i in range(self.rows)]
        texture_arrays = []  # stores the actual pixel data
        current_index = 0
        # we should add tag and layer data too!
        for i in range(self.rows):
            for j in range(self.cols):
                cell = self.__cells[i][j]
                for tag in cell.tags:
                    tags[i][j].append(tag)

                t = cell.texture
                if t not in texture_dict:
                    texture_dict[t] = current_index
                    current_index += 1
                    texture_arrays.append(np.get_array_from_texture(t))
                    
                array_index[i][j] = texture_dict[t]
        print(current_index)
        return (size, texture_arrays, array_index, tags)
Ejemplo n.º 4
0
window = Window()


class ImageSprite(Sprite):
    def on_create(self):
        self.image = "baboon.jpeg"
        self.scale = 2
        self.y = window.height / 2


input_sprite = window.create_sprite(ImageSprite)
input_sprite.x = (window.width - input_sprite.width) / 2
output_sprite = window.create_sprite(ImageSprite)
output_sprite.x = (window.width + output_sprite.width) / 2

image = NumpyImage.get_array_from_texture(input_sprite.texture)
rows, cols, channels = image.shape

img = NumpyImage(rows, cols)
for i in range(rows):
    for j in range(cols):
        intensity = (j * 255) // (cols - 1)
        img[i, j] = intensity

# for i in range(rows):
#     for j in range(cols):
#         channel_sum = 0
#         # print(image[i][j])
#         for k in range(channels - 1):
#             channel_sum = max(channel_sum, image[i][j][k])
#         image[i][j] = [channel_sum, channel_sum, channel_sum, 255]
Ejemplo n.º 5
0
 def get_image_array(self) -> ndarray:
     array = IP.get_array_from_texture(self.texture)
     return array[:, :, :3]