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


Python Image.resize方法代码示例

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


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

示例1: write_images

# 需要导入模块: from SimpleCV.ImageClass import Image [as 别名]
# 或者: from SimpleCV.ImageClass.Image import resize [as 别名]
def write_images(model_path, fgvc_data_dir, images_nos, options):
    if options.crop:
        # read box information
        box_info = {}
        with open(path.join(fgvc_data_dir, 'images_box.txt')) as ibf:
            for line in ibf:
                result = line.split()
                img_no, coords = result[0], map(int, result[1:])
                box_info[img_no] = coords

    for image_no in images_nos:
        image_file = '%s.%s' % (image_no, FGVC_IMAGE_SUFFIX)
        img = Image(path.join(fgvc_data_dir, 'images', image_file))

        if options.crop:
            # although FGVC pages says the orgin is (1,1)
            # still there's some coordinates in box have 0 value
            # so don't do adjustment - 1px difference should be OK
            x1, y1, x2, y2 = box_info[image_no]
            img = img.crop(x1, y1, x2, y2)
        else:
            # remove out banner
            img = img.crop(0, 0, img.width, img.height-FGVC_BANNER_HEIGHT)

        if options.reduce_color_space:
            img = reduce_color_space(img, fast=True)

        if options.grayscale:
            img = img.grayscale()

        # normalize to width
        img = img.resize(NORMALIZED_WIDTH, int(img.height*1.0*NORMALIZED_WIDTH/img.width))
        img.save(path.join(model_path, image_file))
开发者ID:kavinyao,项目名称:airplane-recognition,代码行数:35,代码来源:select-models.py

示例2: applyFilter

# 需要导入模块: from SimpleCV.ImageClass import Image [as 别名]
# 或者: from SimpleCV.ImageClass.Image import resize [as 别名]
    def applyFilter(self, image, grayscale=False):
        """
        **SUMMARY**

        Apply the DFT filter to given image.

        **PARAMETERS**

        * *image*     - SimpleCV.Image image
        * *grayscale* - if this value is True we perfrom the operation on the 
                        DFT of the gray version of the image and the result is
                        gray image. If grayscale is true we perform the 
                        operation on each channel and the recombine them to
                        create the result.

        **RETURNS**

        Filtered Image.

        **EXAMPLE**

        >>> notch = DFT.createNotchFilter(dia1=200, cen=(200, 200),
                                          size=(512, 512), type="highpass")
        >>> img = Image('lenna')
        >>> notch.applyFilter(img).show()
        """

        if self.width == 0 or self.height == 0:
            warnings.warn("Empty Filter. Returning the image.")
            return image
        w, h = image.size()
        if grayscale:
            image = image.toGray()
            print self._numpy.dtype, "gray"
        fltImg = Image(self._numpy)
        if fltImg.size() != image.size():
            fltImg = fltImg.resize(w, h)
        filteredImage = image.applyDFTFilter(fltImg, grayscale)
        return filteredImage
开发者ID:Betrezen,项目名称:SimpleCV2,代码行数:41,代码来源:DFT.py


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