def __init__(self, image1, image2, position): self.imageUp, _ = main.load_image(image1, colorkey=-1, scale=(272, 81)) self.imageDown, _ = main.load_image(image2, colorkey=-1, scale=(272, 81)) self.position = position self.pressed = False
def __init__(self): super().__init__() self.explode_image, _ = main.load_image('enemy_ex.png', colorkey=-1, scale=(96, 102)) self.ash_image, self.rect = main.load_image('enemy_ash.png', colorkey=-1, scale=(96, 102)) self.image = self.explode_image screen = pygame.display.get_surface() self.area = screen.get_rect() self.speed = 2 self.remaining_time = 0 self.wait = 10
def set_image(hwd, image_path): cvImg = backend.load_image(image_path) if cvImg is None: return label_Image = hwd.preview_placeholder widget_h = label_Image.height() widget_w = label_Image.width() img_h, img_w, _ = cvImg.shape if img_h > widget_h or img_w > widget_w: ratio = widget_w / img_w new_w = int(img_w * ratio) new_h = int(img_h * ratio) cvImg = cv2.resize(cvImg, (new_w, new_h)) height, width, channel = cvImg.shape bytesPerLine = 3 * width qImg = QtGui.QImage(cvImg, width, height, bytesPerLine, QtGui.QImage.Format_RGB888).rgbSwapped() qImg = QtGui.QPixmap(qImg) label_Image.setPixmap(qImg) app.processEvents()
def load_raw_img(file_path, idx): with open(file_path, 'r') as f: fgs = f.readlines() bg = fgs[idx].strip().replace('/matting/', '/clip_img/').replace( '/matting_0', '/clip_0').replace('.png', '.jpg') img = load_image(bg) return img
def __init__(self): super().__init__() self.image, self.rect = main.load_image('bullet.png', colorkey=-1, scale=(5, 20)) screen = pygame.display.get_surface() self.area = screen.get_rect() self.speed = 10
class Shop(pygame.sprite.Sprite): image_shop = load_image("shop.png") image_rofl = load_image("rofl.jpg") def __init__(self, *group): # НЕОБХОДИМО вызвать конструктор родительского класса Sprite. # Это очень важно!!! super().__init__(*group) self.image = Shop.image_shop self.image_rofl = Shop.image_rofl self.rect = self.image.get_rect() self.rect.x = 770 self.rect.y = 10 def update(self, *args): self.rect = self.rect.move( random.randrange(3) - 1, random.randrange(3) - 1) if args and args[0].type == pygame.MOUSEBUTTONDOWN and \ self.rect.collidepoint(args[0].pos): self.image = self.image_rofl
def put(self): args = parser.parse_args() text = args['latter_list'] latter_num = int(args['latter_num']) phoneme_num = int(args['phoneme_num']) input_text = args['input_text'] font = int(args['font']) color = args['color'] blur = int(args['blur']) image_width = int(args['image_width']) image_height = int(args['image_height']) is_invisiable = args['is_invisiable'] if is_invisiable == 'false': is_invisiable = False if is_invisiable == 'true': is_invisiable = True bg_filename = args['bg_filename'] bg_data = None if bg_filename: x_in_bg = int(args['x_in_bg']) y_in_bg = int(args['y_in_bg']) bg_data = (bg_filename, x_in_bg, y_in_bg) text = text.replace("'", "\"") text = json.loads(text) latter_list = main.json_to_obj(text) target = latter_list[latter_num][phoneme_num] model_num = phoneme_list.index(target.phoneme) print(target.param_list) target_img = main.load_image(font, model_num, target.param_list) target_img = cv2.resize(target_img, (int(target.width), int(target.height)), interpolation=cv2.INTER_LINEAR) target_img = main.update_rotation(target_img, target.rotation) target.img = target_img filename, cb_filename, image_width, image_height = main.img_attach( latter_list, blur, color, is_invisiable, input_text, bg_data, image_width, image_height) com = 's3cmd put ./static/image/{} s3://seolo/static/image/'.format( filename) os.system(com) text[latter_num][phoneme_num]['img'] = target_img.tolist() res = { "filename": filename, "cb_filename": cb_filename, "latter_list": text } return res
def __init__(self): super().__init__() self.all_images = [ main.load_image('plane_lv{}.png'.format(i), colorkey=-1, scale=(64, 68))[0] for i in range(1, 4) ] self.image = self.all_images[0] self.rect = self.image.get_rect() screen = pygame.display.get_surface() self.area = screen.get_rect() self.radius = max(self.rect.width, self.rect.height) // 2 self.vert = 0 self.horiz = 0 self.speed = 4 self.hp = INITIAL_HP self.power = 0 self.place_at_bottom_center()
def __init__(self): super().__init__() self.image, self.rect = main.load_image('hp_pack.png', colorkey=-1, scale=(25, 25))
def on_load_image_click(self): self.absolute_path = QFileDialog.getOpenFileName(self, 'Open file', '.', "jpg files (*.jpg)") print(self.absolute_path) load_image = main.load_image(self.absolute_path[0]) load_image.getDeepdream()
return np.rint(new_data).astype(np.uint8) def remove_noise(img, img_name, filter_size, filter_function): img_filtered = apply_filter(img.copy(), filter_size, filter_function) img_err, err_left_mean = mean_square_error(img.copy(), img_filtered.copy()) img_diff = img_filtered.astype(np.int) - img.astype(np.int) img_diff = linear_transformation_to_pixel_value_range(img_diff) figures = [] figures.append((img_name + ' orginal image', img)) figures.append((str(filter_function)[9:-19] + 'ed', img_filtered)) figures.append(('Error image', img_diff)) plot_figures(figures, 1, 3) img = load_image('img1noisy.tif', type=0) rows, cols = img.shape rows = rows // 2 cols = cols // 2 img_left = img[:, :cols + 1] img_right = img[:, cols:] remove_noise(img_left, 'Left', 3, max_filter) remove_noise(img_left, 'Left', 3, min_filter) remove_noise(img_left, 'Left', 3, mean_filter) remove_noise(img_left, 'Left', 3, median_filter) remove_noise(img_right, 'Right', 3, max_filter) remove_noise(img_right, 'Right', 3, min_filter) remove_noise(img_right, 'Right', 3, mean_filter) remove_noise(img_right, 'Right', 3, median_filter)