當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。