当前位置: 首页>>代码示例>>Python>>正文


Python Image.FLIP_TOP_BOTTOM属性代码示例

本文整理汇总了Python中PIL.Image.FLIP_TOP_BOTTOM属性的典型用法代码示例。如果您正苦于以下问题:Python Image.FLIP_TOP_BOTTOM属性的具体用法?Python Image.FLIP_TOP_BOTTOM怎么用?Python Image.FLIP_TOP_BOTTOM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在PIL.Image的用法示例。


在下文中一共展示了Image.FLIP_TOP_BOTTOM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_orientation

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def update_orientation(image):
    exif_orientation_tag = 0x0112
    if hasattr(image, '_getexif'):
        exif = image._getexif()
        if exif != None and exif_orientation_tag in exif:
            orientation = exif.get(exif_orientation_tag, 1)
            log_msg('Image has EXIF Orientation: ' + str(orientation))
            # orientation is 1 based, shift to zero based and flip/transpose based on 0-based values
            orientation -= 1
            if orientation >= 4:
                image = image.transpose(Image.TRANSPOSE)
            if orientation == 2 or orientation == 3 or orientation == 6 or orientation == 7:
                image = image.transpose(Image.FLIP_TOP_BOTTOM)
            if orientation == 1 or orientation == 2 or orientation == 5 or orientation == 6:
                image = image.transpose(Image.FLIP_LEFT_RIGHT)
    return image 
开发者ID:Azure-Samples,项目名称:Custom-vision-service-iot-edge-raspberry-pi,代码行数:18,代码来源:predict-amd64.py

示例2: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __init__(
        self, unit, im,
        min_filter=GL_LINEAR, mag_filter=GL_LINEAR,
        wrap_s=GL_REPEAT, wrap_t=GL_REPEAT,
        mipmap=False):
        self.unit = unit
        if isinstance(im, basestring):
            im = Image.open(im)
        im = im.convert('RGBA').transpose(Image.FLIP_TOP_BOTTOM)
        self.size = width, height = im.size
        data = im.tobytes()
        self.handle = glGenTextures(1)
        self.bind()
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t)
        glTexImage2D(
            GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
            GL_UNSIGNED_BYTE, data)
        if mipmap:
            glGenerateMipmap(GL_TEXTURE_2D) 
开发者ID:fogleman,项目名称:pg,代码行数:24,代码来源:core.py

示例3: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __init__(self, *commands, prefixes=None, strict=False):
        """Answers with image containing stylish quote."""

        if not commands:
            commands = ("цитата",)

        super().__init__(*commands, prefixes=prefixes, strict=strict)

        self.q = Image.open(self.get_path("q.png")).resize((40, 40), Image.LANCZOS)
        self.qf = self.q.copy().transpose(Image.FLIP_LEFT_RIGHT).transpose(Image.FLIP_TOP_BOTTOM)

        self.f = ImageFont.truetype(self.get_path("font.ttf"), 24)
        self.fs = ImageFont.truetype(self.get_path("font.ttf"), 16)
        self.fss = ImageFont.truetype(self.get_path("font.ttf"), 15)

        example = self.command_example()
        self.description = [f"Генератор цитат",
                            f"{example} [титул] - перешлите сообщение и укажите титул (по желанию) и "
                             "получите цитату!"] 
开发者ID:ekonda,项目名称:sketal,代码行数:21,代码来源:quote.py

示例4: processBackground

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def processBackground(self):
        if self.data.backgroundFile == "" or os.path.isdir(self.data.backgroundFile) or not os.path.isfile(self.data.backgroundFile):
            self.data.backgroundTexture = None
            self.data.backgroundManualReg = []
            self.updateAlignmentInConfig()
            self.data.backgroundRedraw = True
            return
        else:
            img = PILImage.open(self.data.backgroundFile)
            img.thumbnail((1920, 1080), PILImage.ANTIALIAS)
            img = img.transpose(PILImage.FLIP_TOP_BOTTOM)
            imgBytes = BytesIO()
            img.save(imgBytes, format="png")
            imgBytes.seek(0)
            texture = CoreImage(imgBytes, ext="png").texture
            self.data.backgroundTexture = texture
            if self.data.backgroundManualReg:
                # Already have centers to use; just go on to warp_image
                self.warp_image()
            else:
                # Start the manual alignment process
                self.realignBackground() 
开发者ID:MaslowCNC,项目名称:GroundControl,代码行数:24,代码来源:backgroundMenu.py

示例5: vflip

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def vflip(img):
    """Vertically flip the given PIL Image.
    Args:
        img (PIL Image): Image to be flipped.
    Returns:
        PIL Image: Vertically flipped image.
    """

    is_numpy = isinstance(img, np.ndarray)

    if not _is_pil_image(img):
        if is_numpy:
            img = Image.fromarray(img)
        else:
            raise TypeError(
                'img should be PIL Image or numpy array. \
                Got {}'.format(type(img)))

    img = img.transpose(Image.FLIP_TOP_BOTTOM)

    if is_numpy:
        img = np.array(img)

    return img 
开发者ID:Wizaron,项目名称:instance-segmentation-pytorch,代码行数:26,代码来源:preprocess.py

示例6: __init__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __init__(self, value):

        if isinstance(value, str):
            value = Path(value)

        if isinstance(value, Path):
            self.path = Path(value)
            self._texture = loader.loadTexture(Filename.fromOsSpecific(str(value)))
            self._cached_image = None   # for get_pixel() method

        elif isinstance(value, PandaTexture):
            self._texture = value

        else:
            from PIL import Image
            image = value
            self._texture = PandaTexture()
            self._texture.setup2dTexture(image.width, image.height, PandaTexture.TUnsignedByte, PandaTexture.FRgba)
            self._texture.setRamImageAs(image.transpose(Image.FLIP_TOP_BOTTOM).tobytes(), image.mode)
            self._cached_image = image.transpose(Image.FLIP_TOP_BOTTOM)
            self.path = None



        self.filtering = Texture.default_filtering 
开发者ID:pokepetter,项目名称:ursina,代码行数:27,代码来源:texture.py

示例7: flip

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def flip(self, lr, hr):
        mode = random.choice([0, 1, 2, 3])
        if mode == 0:
            pass
        elif mode == 1:
            lr = lr.transpose(Image.FLIP_LEFT_RIGHT)
            hr = hr.transpose(Image.FLIP_LEFT_RIGHT)
            pass
        elif mode == 2:
            lr = lr.transpose(Image.FLIP_TOP_BOTTOM)
            hr = hr.transpose(Image.FLIP_TOP_BOTTOM)
            pass
        elif mode == 3:
            lr = lr.transpose(Image.FLIP_LEFT_RIGHT)
            hr = hr.transpose(Image.FLIP_LEFT_RIGHT)
            lr = lr.transpose(Image.FLIP_TOP_BOTTOM)
            hr = hr.transpose(Image.FLIP_TOP_BOTTOM)
            pass
        return lr, hr 
开发者ID:wmylxmj,项目名称:Anime-Super-Resolution,代码行数:21,代码来源:utils.py

示例8: load_texture

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def load_texture(path, texture):
    glBindTexture(GL_TEXTURE_2D, texture)
    # Set the texture wrapping parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
    # Set texture filtering parameters
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    # load image
    image = Image.open(path)
    image = image.transpose(Image.FLIP_TOP_BOTTOM)
    img_data = image.convert("RGBA").tobytes()
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img_data)
    return texture


# for use with pygame 
开发者ID:totex,项目名称:Learn-OpenGL-in-python,代码行数:19,代码来源:TextureLoader.py

示例9: transform_xy

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def transform_xy(self, x, y, rng):
      
        if rng.uniform(0.0, 1.0) < self.chance:

            x = x if not isinstance(x, ImageType) else x.transpose(Image.FLIP_TOP_BOTTOM)
            y = y if not isinstance(y, ImageType) else y.transpose(Image.FLIP_TOP_BOTTOM)
            
        return x, y 
开发者ID:mme,项目名称:vergeml,代码行数:10,代码来源:flip_vertical.py

示例10: __call__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __call__(self, img):
        if random.random() < 0.5:
            return img.transpose(Image.FLIP_TOP_BOTTOM)
        return img 
开发者ID:moemen95,项目名称:Pytorch-Project-Template,代码行数:6,代码来源:voc_utils.py

示例11: __call__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __call__(self, images, mask):
        """Randomly flips images and their mask top to bottom.

        Args:
          images: the PIL.Image image to transform.
          mask: the PIL.Image mask to transform.

        Returns:
          The PIL.Image (images, mask) tuple with either images and mask flipped or none of them flipped.
        """

        if random.random() < self.p:
            return [v.transpose(Image.FLIP_TOP_BOTTOM) for v in images], mask.transpose(Image.FLIP_TOP_BOTTOM)
        else:
            return images, mask 
开发者ID:mapbox,项目名称:robosat,代码行数:17,代码来源:transforms.py

示例12: drawCourse

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def drawCourse(cjson):
    global root
    global canvas
    global canvas_image
    data = drawCourseAsImage(cjson)
    im = Image.fromarray((255.0*data).astype(np.uint8), 'RGB').resize((image_width, image_height), Image.NEAREST)
    im = im.transpose(Image.FLIP_TOP_BOTTOM)
    cim = ImageTk.PhotoImage(image=im)

    canvas.img = cim # Need to save reference to ImageTK
    canvas.itemconfig(canvas_image, image = cim)

    drawScorecard(cjson)
    root.update() 
开发者ID:chadrockey,项目名称:TGC-Designer-Tools,代码行数:16,代码来源:tgc_gui.py

示例13: train_mapper

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def train_mapper(sample):
    img_path, label, crop_size, resize_size = sample
    try:
        img = Image.open(img_path)
        # 统一图片大小
        img = img.resize((resize_size, resize_size), Image.ANTIALIAS)
        # 随机水平翻转
        r1 = random.random()
        if r1 > 0.5:
            img = img.transpose(Image.FLIP_LEFT_RIGHT)
        # 随机垂直翻转
        r2 = random.random()
        if r2 > 0.5:
            img = img.transpose(Image.FLIP_TOP_BOTTOM)
        # 随机角度翻转
        r3 = random.randint(-3, 3)
        img = img.rotate(r3, expand=False)
        # 随机裁剪
        r4 = random.randint(0, int(resize_size - crop_size))
        r5 = random.randint(0, int(resize_size - crop_size))
        box = (r4, r5, r4 + crop_size, r5 + crop_size)
        img = img.crop(box)
        # 把图片转换成numpy值
        img = np.array(img).astype(np.float32)
        # 转换成CHW
        img = img.transpose((2, 0, 1))
        # 转换成BGR
        img = img[(2, 1, 0), :, :] / 255.0
        return img, int(label)
    except:
        print("%s 该图片错误,请删除该图片并重新创建图像数据列表" % img_path)


# 获取训练的reader 
开发者ID:yeyupiaoling,项目名称:LearnPaddle2,代码行数:36,代码来源:reader.py

示例14: __call__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __call__(self, img):
        """
        Args:
            img (PIL.Image): Image to be flipped.
        Returns:
            PIL.Image: Randomly flipped image.
        """
        if self.p < 0.5:
            if isinstance(img, np.ndarray):
                return np.flipud(img).copy()
            else:
                return img.transpose(Image.FLIP_TOP_BOTTOM)
        return img 
开发者ID:tomrunia,项目名称:PyTorchConv3D,代码行数:15,代码来源:spatial_transforms.py

示例15: __call__

# 需要导入模块: from PIL import Image [as 别名]
# 或者: from PIL.Image import FLIP_TOP_BOTTOM [as 别名]
def __call__(self, img, label):
        """
        Args:
            img (PIL Image): Image to be flipped.
        Returns:
            PIL Image: Randomly flipped image.
        """
        if random.random() < self.p:
            img = img.transpose(Image.FLIP_LEFT_RIGHT)
            label = label.transpose(Image.FLIP_LEFT_RIGHT) #left or right
        if random.random() < self.p:
            img = img.transpose(Image.FLIP_TOP_BOTTOM)
            label = label.transpose(Image.FLIP_TOP_BOTTOM) # bottom or top
        return img, label 
开发者ID:mapleneverfade,项目名称:pytorch-semantic-segmentation,代码行数:16,代码来源:functional.py


注:本文中的PIL.Image.FLIP_TOP_BOTTOM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。