Пример #1
0
def generate_images(im_ch, man_ch):
    data = pd.read_excel('VeinsCoordsV05.xlsx')
    ch = 0
    print('Сгенерированные изображения:', end=' ')
    for i in range(1, man_ch + 1):
        oneman_im_ch = 1
        ch += 1
        filename = create_filename(i)
        draw_img = Drawing()
        draw_img.stroke_color = Color("white")
        img = WandImage(width=334, height=118, background=Color("black"))
        img.save(filename=filename)
        for j in func_dict.keys():
            vein = data.iloc[j - 2, 7:]
            start_coord, finish_coord = data.iloc[j - 2, 1], data.iloc[j - 2,
                                                                       3]
            x, y = prepare_data(vein)
            popt, _ = curve_fit(func_dict.get(j), x, y)
            for k in range(popt.shape[0]):
                a, b = find_random_diap(popt[k], j)
                popt[k] = random.uniform(a, b)
            if j in vein_width_dict.keys():
                brush_width = random.uniform(
                    vein_width_dict.get(j)[0],
                    vein_width_dict.get(j)[1])
            else:
                brush_width = random.uniform(1, 1.5)
            create_line_img(start_coord, finish_coord, brush_width, popt, img,
                            filename)
        img.blur(radius=0, sigma=1)
        img.crop(46, 25, 321, 90)
        img.save(filename=filename)
        oneman_vein_name = filename
        print(ch, end=' ')
        while (oneman_im_ch < im_ch // man_ch) or (
            (ch + im_ch % man_ch == im_ch) and (im_ch % man_ch)):
            img = WandImage(filename=oneman_vein_name)
            x1_crop = random.randint(0, 40)
            y1_crop = random.randint(0, 2)
            x2_crop = random.randint(265, 275)
            y2_crop = random.randint(60, 63)
            if random.random() >= 0.4:
                alpha = random.randint(-2, 2)
                img.rotate(alpha, background=Color('black'))
            img.crop(x1_crop, y1_crop, x2_crop, y2_crop)
            if random.random() >= 0.5:
                rad = random.randint(1, 10)
                alpha = random.randint(-45, 45)
                img.motion_blur(radius=rad, sigma=8, angle=alpha)
            filename = oneman_vein_name.replace(
                '.png', '_' + str(oneman_im_ch) + '.png')
            img.save(filename=filename)
            oneman_im_ch += 1
            ch += 1
            print(ch, end=' ')
    print('')
    print('Изображения сгенерированы')
Пример #2
0
 def shadow(self, x, y, radius=2, sigma=4, fresh=False, color="Black"):
     if fresh or not hasattr(self, "pre_shadow") or self.pre_shadow is None:
         shadow = self.color_overlay(color, fresh=False).clone()
         image = Image(width=int(self.template["width"]),
                       height=int(self.template["height"]))
         image.composite(shadow,
                         int(self["left"]) + x,
                         int(self["top"]) + y)
         image.blur(radius, sigma)
         self.pre_shadow = image
     return self.pre_shadow
Пример #3
0
def blur(image: Image, radius: float, sigma: float) -> None:
    image.blur(radius=radius, sigma=sigma)
Пример #4
0
def _blur(img: Image):
    img.blur(0, 5)

    return img
Пример #5
0
def blur(img: Image):
    resize(img)
    img.blur(0, 5)

    return img