2016-12-24 17:18:25 u010402786 阅读数 11742

  针对模糊图像的处理,个人觉得主要分两条路,一种是自我激发型,另外一种属于外部学习型。接下来我们一起学习这两条路的具体方式。

第一种 自我激发型

  基于图像处理的方法,如图像增强和图像复原,以及曾经很火的超分辨率算法。都是在不增加额外信息的前提下的实现方式。
  
1. 图像增强

  图像增强是图像预处理中非常重要且常用的一种方法,图像增强不考虑图像质量下降的原因,只是选择地突出图像中感兴趣的特征,抑制其它不需要的特征,主要目的就是提高图像的视觉效果。先上一张示例图:
  
  这里写图片描述
  
  图像增强中常见的几种具体处理方法为:

  1. 直方图均衡

      在图像处理中,图像直方图表示了图像中像素灰度值的分布情况。为使图像变得清晰,增大反差,凸显图像细节,通常希望图像灰度的分布从暗到亮大致均匀。直方图均衡就是把那些直方图分布不均匀的图像(如大部分像素灰度集中分布在某一段)经过一种函数变换,使之成一幅具有均匀灰度分布的新图像,其灰度直方图的动态范围扩大。用于直方均衡化的变换函数不是统一的,它是输入图像直方图的积分,即累积分布函数。

  2. 灰度变换

      灰度变换可使图像动态范围增大,对比度得到扩展,使图像清晰、特征明显,是图像增强的重要手段之一。它主要利用图像的点运算来修正像素灰度,由输入像素点的灰度值确定相应输出像素点的灰度值,可以看作是“从像素到像素”的变换操作,不改变图像内的空间关系。像素灰度级的改变是根据输入图像f(x,y)灰度值和输出图像g(x,y)灰度值之间的转换函数g(x,y)=T[f(x,y)]进行的。
      灰度变换包含的方法很多,如逆反处理、阈值变换、灰度拉伸、灰度切分、灰度级修正、动态范围调整等。

  3. 图像平滑

      在空间域中进行平滑滤波技术主要用于消除图像中的噪声,主要有邻域平均法、中值滤波法等等。这种局部平均的方法在削弱噪声的同时,常常会带来图像细节信息的损失。
      邻域平均,也称均值滤波,对于给定的图像f(x,y)中的每个像素点(x,y),它所在邻域S中所有M个像素灰度值平均值为其滤波输出,即用一像素邻域内所有像素的灰度平均值来代替该像素原来的灰度。
      中值滤波,对于给定像素点(x,y)所在领域S中的n个像素值数值{f1,f2,…,fn},将它们按大小进行有序排列,位于中间位置的那个像素数值称为这n个数值的中值。某像素点中值滤波后的输出等于该像素点邻域中所有像素灰度的中值。中值滤波是一种非线性滤波,运算简单,实现方便,而且能较好的保护边界。

  4. 图像锐化

      采集图像变得模糊的原因往往是图像受到了平均或者积分运算,因此,如果对其进行微分运算,就可以使边缘等细节信息变得清晰。这就是在空间域中的图像锐化处理,其的基本方法是对图像进行微分处理,并且将运算结果与原图像叠加。从频域中来看,锐化或微分运算意味着对高频分量的提升。常见的连续变量的微分运算有一阶的梯度运算、二阶的拉普拉斯算子运算,它们分别对应离散变量的一阶差分和二阶差分运算。

2. 图像复原

  这里写图片描述
  
  其目标是对退化(传播过程中的噪声啊,大气扰动啊好多原因)的图像进行处理,尽可能获得未退化的原始图像。如果把退化过程当一个黑匣子(系统H),图片经过这个系统变成了一个较烂的图。这类原因可能是光学系统的像差或离焦、摄像系统与被摄物之间的相对运动、电子或光学系统的噪声和介于摄像系统与被摄像物间的大气湍流等。图像复原常用二种方法。当不知道图像本身的性质时,可以建立退化源的数学模型,然后施行复原算法除去或减少退化源的影响。当有了关于图像本身的先验知识时,可以建立原始图像的模型,然后在观测到的退化图像中通过检测原始图像而复原图像。
  
3. 图像超分辨率  
  一张图我们想脑补细节信息好难,但是相似的多幅图我们就能互相脑洞了。所以,我们可以通过一系列相似的低分辨图来共同脑补出一张高清晰图啊,有了这一张犯罪人的脸,我就可以画通缉令了啊。。。
  超分辨率复原技术的目的就是要在提高图像质量的同时恢复成像系统截止频率之外的信息,重建高于系统分辨率的图像。继续说超分辨,它其实就是根据多幅低质量的图片间的关系以及一些先验知识来重构一个高分辨的图片。示例图如下:
这里写图片描述

第二种 外部学习型

  外部学习型,就如同照葫芦画瓢一样的道理。其算法主要是深度学习中的卷积神经网络,我们在待处理信息量不可扩充的前提下(即模糊的图像本身就未包含场景中的细节信息),可以借助海量的同类数据或相似数据训练一个神经网络,然后让神经网络获得对图像内容进行理解、判断和预测的功能,这时候,再把待处理的模糊图像输入,神经网络就会自动为其添加细节,尽管这种添加仅仅是一种概率层面的预测,并非一定准确。

  本文介绍一种在灰度图像复原成彩色RGB图像方面的代表性工作:《全局和局部图像的联合端到端学习图像自动着色并且同时进行分类》。利用神经网络给黑白图像上色,使其变为彩色图像。稍作解释,黑白图像,实际上只有一个通道的信息,即灰度信息。彩色图像,则为RGB图像(其他颜色空间不一一列举,仅以RGB为例讲解),有三个通道的信息。彩色图像转换为黑白图像极其简单,属于有损压缩数据;反之则很难,因为数据不会凭空增多。

  搭建一个神经网络,给一张黑白图像,然后提供大量与其相同年代的彩色图像作为训练数据(色调比较接近),然后输入黑白图像,人工智能按照之前的训练结果为其上色,输出彩色图像,先来看一张效果图:
  这里写图片描述

  1. 本文工作
    •  用户无干预的灰度图像着色方法。
    •  一个新颖的端到端网络,联合学习图像的全局和局部特征。
    •  一种利用分类标签提高性能的学习方法。
    •  基于利用全局特征的风格转换技术。
    •  通过用户研究和许多不同的例子深入评估模型,包括百年的黑白照片。

  2. 着色框架
      
      模型框架包括四个主要组件:低级特征提取网络,中级特征提取网络,全局特征提取网络和着色网络。 这些部件都以端对端的方式紧密耦合和训练。 模型的输出是图像的色度,其与亮度融合以形成输出图像。
               这里写图片描述

  3. 与另外两个工作对比

    • Gustav Larsson, Michael Maire, and Gregory Shakhnarovich. Learning Representations for Automatic Colorization. In ECCV 2016.
    •Richard Zhang, Phillip Isola, and Alexei A. Efros. Colorful Image Colorization. In ECCV 2016.

这里写图片描述

参考文献:

网页:
http://hi.cs.waseda.ac.jp/~iizuka/projects/colorization/extra.html

代码:
https://github.com/satoshiiizuka/siggraph2016_colorization

论文2:
http://richzhang.github.io/colorization/

在线demo:
http://demos.algorithmia.com/colorize-photos/

2017-03-29 16:55:13 yh_1988 阅读数 270

机器人那么火,自动驾驶那么火。想想我也是学过图像识别的人,别人问我图像卷积都不知道了,最近的状态也有点小尴尬:工作有点闲,业余学习还有点忙。借用工作闲暇时间充个电,补补图像处理知识吧。


讨论到数字图像处理。想到的第一个参考书籍就是冈萨雷的《数字图像处理》


数字图像处理大多可分为3个步骤

第一步 图像增强

第二步 提取特征

第三步 分析解释

------------------------------------------我就是分割线-------------------------------------------------------

《数字图像处理》一书根据书本结构定义数字图像处理的框图为:



其中对应2~9章为图像增强

10章为特征提取

11~12章为分析解释

------------------------------------------我也是分割线-------------------------------------------------------

图像增强:随着现在传感器技术的不断提升,多数场合可以弱化图像增强处理步骤。

特征提取:如边缘检测,轮廓检测,区域定位等等

分析解释:将抽象出来的特征进行软件分析与识别。

------------------------------------------我还是分割线-------------------------------------------------------

其中为了提高处理速度,图像增强与特征提取两步多数在可并行的处理器结构中实现:如FPGA,目的从大数据量的图片里提取出少量需要的有用信息。

分析解释涉及到的运算量最大,输入信息较少,可以直接由CPU来执行。



2015-05-03 11:38:39 qunxingvip 阅读数 3227

简介

图像处理最近几年也是很火的。PIL (Python Imaging Library)是 Python 中最常用的图像处理库,支持众多图像格式,可用于执行裁剪、大小调整、旋转、滤镜效果等操作。

基本说明

导入PIL模块:

import PIL
 from PIL import Image

用的Python2.7上面两个方法都可以。
查看帮助文档:
help(PIL)结果:

 help(PIL)
Help on package PIL:

NAME
    PIL

FILE
    c:\python27\lib\site-packages\pil\__init__.py

DESCRIPTION
    # The Python Imaging Library.
    # $Id$
    #
    # package placeholder
    #
    # Copyright (c) 1999 by Secret Labs AB.
    #
    # See the README file for information on usage and redistribution.
    #

PACKAGE CONTENTS
    ArgImagePlugin
    BdfFontFile
    BmpImagePlugin
    BufrStubImagePlugin
    ContainerIO
    CurImagePlugin
    DcxImagePlugin
    EpsImagePlugin
    ExifTags
    FitsStubImagePlugin
    FliImagePlugin
    FontFile
    FpxImagePlugin
    GbrImagePlugin
    GdImageFile
    GifImagePlugin
    GimpGradientFile
    GimpPaletteFile
    GribStubImagePlugin
    Hdf5StubImagePlugin
    IcnsImagePlugin
    IcoImagePlugin
    ImImagePlugin
    Image
    ImageChops
    ImageCms
    ImageColor
    ImageDraw
    ImageDraw2
    ImageEnhance
    ImageFile
    ImageFileIO
    ImageFilter
    ImageFont
    ImageGrab
    ImageMath
    ImageMode
    ImageOps
    ImagePalette
    ImagePath
    ImageQt
    ImageSequence
    ImageShow
    ImageStat
    ImageTk
    ImageTransform
    ImageWin
    ImtImagePlugin
    IptcImagePlugin
    Jpeg2KImagePlugin
    JpegImagePlugin
    JpegPresets
    McIdasImagePlugin
    MicImagePlugin
    MpegImagePlugin
    MspImagePlugin
    OleFileIO
    PSDraw
    PaletteFile
    PalmImagePlugin
    PcdImagePlugin
    PcfFontFile
    PcxImagePlugin
    PdfImagePlugin
    PixarImagePlugin
    PngImagePlugin
    PpmImagePlugin
    PsdImagePlugin
    PyAccess
    SgiImagePlugin
    SpiderImagePlugin
    SunImagePlugin
    TarIO
    TgaImagePlugin
    TiffImagePlugin
    TiffTags
    WalImageFile
    WebPImagePlugin
    WmfImagePlugin
    XVThumbImagePlugin
    XbmImagePlugin
    XpmImagePlugin
    _binary
    _imaging
    _imagingcms
    _imagingft
    _imagingmath
    _imagingtk
    _util
    _webp
    tests

DATA
    PILLOW_VERSION = '2.4.0'
    VERSION = '1.1.7'

help(Image)结果:

help(Image)
Help on module PIL.Image in PIL:

NAME
    PIL.Image

FILE
    c:\python27\lib\site-packages\pil\image.py

DESCRIPTION
    # The Python Imaging Library.
    # $Id$
    #
    # the Image class wrapper
    #
    # partial release history:
    # 1995-09-09 fl   Created
    # 1996-03-11 fl   PIL release 0.0 (proof of concept)
    # 1996-04-30 fl   PIL release 0.1b1
    # 1999-07-28 fl   PIL release 1.0 final
    # 2000-06-07 fl   PIL release 1.1
    # 2000-10-20 fl   PIL release 1.1.1
    # 2001-05-07 fl   PIL release 1.1.2
    # 2002-03-15 fl   PIL release 1.1.3
    # 2003-05-10 fl   PIL release 1.1.4
    # 2005-03-28 fl   PIL release 1.1.5
    # 2006-12-02 fl   PIL release 1.1.6
    # 2009-11-15 fl   PIL release 1.1.7
    #
    # Copyright (c) 1997-2009 by Secret Labs AB.  All rights reserved.
    # Copyright (c) 1995-2009 by Fredrik Lundh.
    #
    # See the README file for information on usage and redistribution.
    #

CLASSES
    Image
    ImagePointHandler
    ImageTransformHandler

    class Image
     |  This class represents an image object.  To create
     |  :py:class:`~PIL.Image.Image` objects, use the appropriate factory
     |  functions.  There's hardly ever any reason to call the Image constructor
     |  directly.
     |  
     |  * :py:func:`~PIL.Image.open`
     |  * :py:func:`~PIL.Image.new`
     |  * :py:func:`~PIL.Image.frombytes`
     |  
     |  Methods defined here:
     |  
     |  __getattr__(self, name)
     |  
     |  __init__(self)
     |  
     |  __repr__(self)
     |  
     |  convert(self, mode=None, matrix=None, dither=None, palette=0, colors=256)
     |      Returns a converted copy of this image. For the "P" mode, this
     |      method translates pixels through the palette.  If mode is
     |      omitted, a mode is chosen so that all information in the image
     |      and the palette can be represented without a palette.
     |      
     |      The current version supports all possible conversions between
     |      "L", "RGB" and "CMYK." The **matrix** argument only supports "L"
     |      and "RGB".
     |      
     |      When translating a color image to black and white (mode "L"),
     |      the library uses the ITU-R 601-2 luma transform::
     |      
     |          L = R * 299/1000 + G * 587/1000 + B * 114/1000
     |      
     |      The default method of converting a greyscale ("L") or "RGB"
     |      image into a bilevel (mode "1") image uses Floyd-Steinberg
     |      dither to approximate the original image luminosity levels. If
     |      dither is NONE, all non-zero values are set to 255 (white). To
     |      use other thresholds, use the :py:meth:`~PIL.Image.Image.point`
     |      method.
     |      
     |      :param mode: The requested mode.
     |      :param matrix: An optional conversion matrix.  If given, this
     |         should be 4- or 16-tuple containing floating point values.
     |      :param dither: Dithering method, used when converting from
     |         mode "RGB" to "P" or from "RGB" or "L" to "1".
     |         Available methods are NONE or FLOYDSTEINBERG (default).
     |      :param palette: Palette to use when converting from mode "RGB"
     |         to "P".  Available palettes are WEB or ADAPTIVE.
     |      :param colors: Number of colors to use for the ADAPTIVE palette.
     |         Defaults to 256.
     |      :rtype: :py:class:`~PIL.Image.Image`
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  copy(self)
     |      Copies this image. Use this method if you wish to paste things
     |      into an image, but still retain the original.
     |      
     |      :rtype: :py:class:`~PIL.Image.Image`
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  crop(self, box=None)
     |      Returns a rectangular region from this image. The box is a
     |      4-tuple defining the left, upper, right, and lower pixel
     |      coordinate.
     |      
     |      This is a lazy operation.  Changes to the source image may or
     |      may not be reflected in the cropped image.  To break the
     |      connection, call the :py:meth:`~PIL.Image.Image.load` method on
     |      the cropped copy.
     |      
     |      :param box: The crop rectangle, as a (left, upper, right, lower)-tuple.
     |      :rtype: :py:class:`~PIL.Image.Image`
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  draft(self, mode, size)
     |      NYI
     |      
     |      Configures the image file loader so it returns a version of the
     |      image that as closely as possible matches the given mode and
     |      size.  For example, you can use this method to convert a color
     |      JPEG to greyscale while loading it, or to extract a 128x192
     |      version from a PCD file.
     |      
     |      Note that this method modifies the :py:class:`~PIL.Image.Image` object
     |      in place.  If the image has already been loaded, this method has no
     |      effect.
     |      
     |      :param mode: The requested mode.
     |      :param size: The requested size.
     |  
     |  filter(self, filter)
     |      Filters this image using the given filter.  For a list of
     |      available filters, see the :py:mod:`~PIL.ImageFilter` module.
     |      
     |      :param filter: Filter kernel.
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  frombytes(self, data, decoder_name='raw', *args)
     |      Loads this image with pixel data from a bytes object.
     |      
     |      This method is similar to the :py:func:`~PIL.Image.frombytes` function,
     |      but loads data into this image instead of creating a new image object.
     |  
     |  fromstring(self, *args, **kw)
     |      Deprecated alias to frombytes.
     |      
     |      .. deprecated:: 2.0
     |  
     |  getbands(self)
     |      Returns a tuple containing the name of each band in this image.
     |      For example, **getbands** on an RGB image returns ("R", "G", "B").
     |      
     |      :returns: A tuple containing band names.
     |      :rtype: tuple
     |  
     |  getbbox(self)
     |      Calculates the bounding box of the non-zero regions in the
     |      image.
     |      
     |      :returns: The bounding box is returned as a 4-tuple defining the
     |         left, upper, right, and lower pixel coordinate. If the image
     |         is completely empty, this method returns None.
     |  
     |  getcolors(self, maxcolors=256)
     |      Returns a list of colors used in this image.
     |      
     |      :param maxcolors: Maximum number of colors.  If this number is
     |         exceeded, this method returns None.  The default limit is
     |         256 colors.
     |      :returns: An unsorted list of (count, pixel) values.
     |  
     |  getdata(self, band=None)
     |      Returns the contents of this image as a sequence object
     |      containing pixel values.  The sequence object is flattened, so
     |      that values for line one follow directly after the values of
     |      line zero, and so on.
     |      
     |      Note that the sequence object returned by this method is an
     |      internal PIL data type, which only supports certain sequence
     |      operations.  To convert it to an ordinary sequence (e.g. for
     |      printing), use **list(im.getdata())**.
     |      
     |      :param band: What band to return.  The default is to return
     |         all bands.  To return a single band, pass in the index
     |         value (e.g. 0 to get the "R" band from an "RGB" image).
     |      :returns: A sequence-like object.
     |  
     |  getextrema(self)
     |      Gets the the minimum and maximum pixel values for each band in
     |      the image.
     |      
     |      :returns: For a single-band image, a 2-tuple containing the
     |         minimum and maximum pixel value.  For a multi-band image,
     |         a tuple containing one 2-tuple for each band.
     |  
     |  getim(self)
     |      Returns a capsule that points to the internal image memory.
     |      
     |      :returns: A capsule object.
     |  
     |  getpalette(self)
     |      Returns the image palette as a list.
     |      
     |      :returns: A list of color values [r, g, b, ...], or None if the
     |         image has no palette.
     |  
     |  getpixel(self, xy)
     |      Returns the pixel value at a given position.
     |      
     |      :param xy: The coordinate, given as (x, y).
     |      :returns: The pixel value.  If the image is a multi-layer image,
     |         this method returns a tuple.
     |  
     |  getprojection(self)
     |      Get projection to x and y axes
     |      
     |      :returns: Two sequences, indicating where there are non-zero
     |          pixels along the X-axis and the Y-axis, respectively.
     |  
     |  histogram(self, mask=None, extrema=None)
     |      Returns a histogram for the image. The histogram is returned as
     |      a list of pixel counts, one for each pixel value in the source
     |      image. If the image has more than one band, the histograms for
     |      all bands are concatenated (for example, the histogram for an
     |      "RGB" image contains 768 values).
     |      
     |      A bilevel image (mode "1") is treated as a greyscale ("L") image
     |      by this method.
     |      
     |      If a mask is provided, the method returns a histogram for those
     |      parts of the image where the mask image is non-zero. The mask
     |      image must have the same size as the image, and be either a
     |      bi-level image (mode "1") or a greyscale image ("L").
     |      
     |      :param mask: An optional mask.
     |      :returns: A list containing pixel counts.
     |  
     |  load(self)
     |      Allocates storage for the image and loads the pixel data.  In
     |      normal cases, you don't need to call this method, since the
     |      Image class automatically loads an opened image when it is
     |      accessed for the first time.
     |      
     |      :returns: An image access object.
     |  
     |  offset(self, xoffset, yoffset=None)
     |      .. deprecated:: 2.0
     |      
     |      .. note:: New code should use :py:func:`PIL.ImageChops.offset`.
     |      
     |      Returns a copy of the image where the data has been offset by the given
     |      distances. Data wraps around the edges. If **yoffset** is omitted, it
     |      is assumed to be equal to **xoffset**.
     |      
     |      :param xoffset: The horizontal distance.
     |      :param yoffset: The vertical distance.  If omitted, both
     |         distances are set to the same value.
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  paste(self, im, box=None, mask=None)
     |      Pastes another image into this image. The box argument is either
     |      a 2-tuple giving the upper left corner, a 4-tuple defining the
     |      left, upper, right, and lower pixel coordinate, or None (same as
     |      (0, 0)).  If a 4-tuple is given, the size of the pasted image
     |      must match the size of the region.
     |      
     |      If the modes don't match, the pasted image is converted to the mode of
     |      this image (see the :py:meth:`~PIL.Image.Image.convert` method for
     |      details).
     |      
     |      Instead of an image, the source can be a integer or tuple
     |      containing pixel values.  The method then fills the region
     |      with the given color.  When creating RGB images, you can
     |      also use color strings as supported by the ImageColor module.
     |      
     |      If a mask is given, this method updates only the regions
     |      indicated by the mask.  You can use either "1", "L" or "RGBA"
     |      images (in the latter case, the alpha band is used as mask).
     |      Where the mask is 255, the given image is copied as is.  Where
     |      the mask is 0, the current value is preserved.  Intermediate
     |      values can be used for transparency effects.
     |      
     |      Note that if you paste an "RGBA" image, the alpha band is
     |      ignored.  You can work around this by using the same image as
     |      both source image and mask.
     |      
     |      :param im: Source image or pixel value (integer or tuple).
     |      :param box: An optional 4-tuple giving the region to paste into.
     |         If a 2-tuple is used instead, it's treated as the upper left
     |         corner.  If omitted or None, the source is pasted into the
     |         upper left corner.
     |      
     |         If an image is given as the second argument and there is no
     |         third, the box defaults to (0, 0), and the second argument
     |         is interpreted as a mask image.
     |      :param mask: An optional mask image.
     |  
     |  point(self, lut, mode=None)
     |      Maps this image through a lookup table or function.
     |      
     |      :param lut: A lookup table, containing 256 (or 65336 if
     |         self.mode=="I" and mode == "L") values per band in the
     |         image.  A function can be used instead, it should take a
     |         single argument. The function is called once for each
     |         possible pixel value, and the resulting table is applied to
     |         all bands of the image.
     |      :param mode: Output mode (default is same as input).  In the
     |         current version, this can only be used if the source image
     |         has mode "L" or "P", and the output has mode "1" or the
     |         source image mode is "I" and the output mode is "L".
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  putalpha(self, alpha)
     |      Adds or replaces the alpha layer in this image.  If the image
     |      does not have an alpha layer, it's converted to "LA" or "RGBA".
     |      The new layer must be either "L" or "1".
     |      
     |      :param alpha: The new alpha layer.  This can either be an "L" or "1"
     |         image having the same size as this image, or an integer or
     |         other color value.
     |  
     |  putdata(self, data, scale=1.0, offset=0.0)
     |      Copies pixel data to this image.  This method copies data from a
     |      sequence object into the image, starting at the upper left
     |      corner (0, 0), and continuing until either the image or the
     |      sequence ends.  The scale and offset values are used to adjust
     |      the sequence values: **pixel = value*scale + offset**.
     |      
     |      :param data: A sequence object.
     |      :param scale: An optional scale value.  The default is 1.0.
     |      :param offset: An optional offset value.  The default is 0.0.
     |  
     |  putpalette(self, data, rawmode='RGB')
     |      Attaches a palette to this image.  The image must be a "P" or
     |      "L" image, and the palette sequence must contain 768 integer
     |      values, where each group of three values represent the red,
     |      green, and blue values for the corresponding pixel
     |      index. Instead of an integer sequence, you can use an 8-bit
     |      string.
     |      
     |      :param data: A palette sequence (either a list or a string).
     |  
     |  putpixel(self, xy, value)
     |      Modifies the pixel at the given position. The color is given as
     |      a single numerical value for single-band images, and a tuple for
     |      multi-band images.
     |      
     |      Note that this method is relatively slow.  For more extensive changes,
     |      use :py:meth:`~PIL.Image.Image.paste` or the :py:mod:`~PIL.ImageDraw`
     |      module instead.
     |      
     |      See:
     |      
     |      * :py:meth:`~PIL.Image.Image.paste`
     |      * :py:meth:`~PIL.Image.Image.putdata`
     |      * :py:mod:`~PIL.ImageDraw`
     |      
     |      :param xy: The pixel coordinate, given as (x, y).
     |      :param value: The pixel value.
     |  
     |  quantize(self, colors=256, method=None, kmeans=0, palette=None)
     |  
     |  resize(self, size, resample=0)
     |      Returns a resized copy of this image.
     |      
     |      :param size: The requested size in pixels, as a 2-tuple:
     |         (width, height).
     |      :param resample: An optional resampling filter.  This can be
     |         one of :py:attr:`PIL.Image.NEAREST` (use nearest neighbour),
     |         :py:attr:`PIL.Image.BILINEAR` (linear interpolation in a 2x2
     |         environment), :py:attr:`PIL.Image.BICUBIC` (cubic spline
     |         interpolation in a 4x4 environment), or
     |         :py:attr:`PIL.Image.ANTIALIAS` (a high-quality downsampling filter).
     |         If omitted, or if the image has mode "1" or "P", it is
     |         set :py:attr:`PIL.Image.NEAREST`.
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  rotate(self, angle, resample=0, expand=0)
     |      Returns a rotated copy of this image.  This method returns a
     |      copy of this image, rotated the given number of degrees counter
     |      clockwise around its centre.
     |      
     |      :param angle: In degrees counter clockwise.
     |      :param filter: An optional resampling filter.  This can be
     |         one of :py:attr:`PIL.Image.NEAREST` (use nearest neighbour),
     |         :py:attr:`PIL.Image.BILINEAR` (linear interpolation in a 2x2
     |         environment), or :py:attr:`PIL.Image.BICUBIC`
     |         (cubic spline interpolation in a 4x4 environment).
     |         If omitted, or if the image has mode "1" or "P", it is
     |         set :py:attr:`PIL.Image.NEAREST`.
     |      :param expand: Optional expansion flag.  If true, expands the output
     |         image to make it large enough to hold the entire rotated image.
     |         If false or omitted, make the output image the same size as the
     |         input image.
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  save(self, fp, format=None, **params)
     |      Saves this image under the given filename.  If no format is
     |      specified, the format to use is determined from the filename
     |      extension, if possible.
     |      
     |      Keyword options can be used to provide additional instructions
     |      to the writer. If a writer doesn't recognise an option, it is
     |      silently ignored. The available options are described later in
     |      this handbook.
     |      
     |      You can use a file object instead of a filename. In this case,
     |      you must always specify the format. The file object must
     |      implement the **seek**, **tell**, and **write**
     |      methods, and be opened in binary mode.
     |      
     |      :param file: File name or file object.
     |      :param format: Optional format override.  If omitted, the
     |         format to use is determined from the filename extension.
     |         If a file object was used instead of a filename, this
     |         parameter should always be used.
     |      :param options: Extra parameters to the image writer.
     |      :returns: None
     |      :exception KeyError: If the output format could not be determined
     |         from the file name.  Use the format option to solve this.
     |      :exception IOError: If the file could not be written.  The file
     |         may have been created, and may contain partial data.
     |  
     |  seek(self, frame)
     |      Seeks to the given frame in this sequence file. If you seek
     |      beyond the end of the sequence, the method raises an
     |      **EOFError** exception. When a sequence file is opened, the
     |      library automatically seeks to frame 0.
     |      
     |      Note that in the current version of the library, most sequence
     |      formats only allows you to seek to the next frame.
     |      
     |      See :py:meth:`~PIL.Image.Image.tell`.
     |      
     |      :param frame: Frame number, starting at 0.
     |      :exception EOFError: If the call attempts to seek beyond the end
     |          of the sequence.
     |  
     |  show(self, title=None, command=None)
     |      Displays this image. This method is mainly intended for
     |      debugging purposes.
     |      
     |      On Unix platforms, this method saves the image to a temporary
     |      PPM file, and calls the **xv** utility.
     |      
     |      On Windows, it saves the image to a temporary BMP file, and uses
     |      the standard BMP display utility to show it (usually Paint).
     |      
     |      :param title: Optional title to use for the image window,
     |         where possible.
     |      :param command: command used to show the image
     |  
     |  split(self)
     |      Split this image into individual bands. This method returns a
     |      tuple of individual image bands from an image. For example,
     |      splitting an "RGB" image creates three new images each
     |      containing a copy of one of the original bands (red, green,
     |      blue).
     |      
     |      :returns: A tuple containing bands.
     |  
     |  tell(self)
     |      Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`.
     |      
     |      :returns: Frame number, starting with 0.
     |  
     |  thumbnail(self, size, resample=0)
     |      Make this image into a thumbnail.  This method modifies the
     |      image to contain a thumbnail version of itself, no larger than
     |      the given size.  This method calculates an appropriate thumbnail
     |      size to preserve the aspect of the image, calls the
     |      :py:meth:`~PIL.Image.Image.draft` method to configure the file reader
     |      (where applicable), and finally resizes the image.
     |      
     |      Note that the bilinear and bicubic filters in the current
     |      version of PIL are not well-suited for thumbnail generation.
     |      You should use :py:attr:`PIL.Image.ANTIALIAS` unless speed is much more
     |      important than quality.
     |      
     |      Also note that this function modifies the :py:class:`~PIL.Image.Image`
     |      object in place.  If you need to use the full resolution image as well, apply
     |      this method to a :py:meth:`~PIL.Image.Image.copy` of the original image.
     |      
     |      :param size: Requested size.
     |      :param resample: Optional resampling filter.  This can be one
     |         of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BILINEAR`,
     |         :py:attr:`PIL.Image.BICUBIC`, or :py:attr:`PIL.Image.ANTIALIAS`
     |         (best quality).  If omitted, it defaults to
     |         :py:attr:`PIL.Image.NEAREST` (this will be changed to ANTIALIAS in a
     |         future version).
     |      :returns: None
     |  
     |  tobitmap(self, name='image')
     |      Returns the image converted to an X11 bitmap.
     |      
     |      .. note:: This method only works for mode "1" images.
     |      
     |      :param name: The name prefix to use for the bitmap variables.
     |      :returns: A string containing an X11 bitmap.
     |      :raises ValueError: If the mode is not "1"
     |  
     |  tobytes(self, encoder_name='raw', *args)
     |      Return image as a bytes object
     |      
     |      :param encoder_name: What encoder to use.  The default is to
     |                           use the standard "raw" encoder.
     |      :param args: Extra arguments to the encoder.
     |      :rtype: A bytes object.
     |  
     |  tostring(self, *args, **kw)
     |      # Declare tostring as alias to tobytes
     |  
     |  transform(self, size, method, data=None, resample=0, fill=1)
     |      Transforms this image.  This method creates a new image with the
     |      given size, and the same mode as the original, and copies data
     |      to the new image using the given transform.
     |      
     |      :param size: The output size.
     |      :param method: The transformation method.  This is one of
     |        :py:attr:`PIL.Image.EXTENT` (cut out a rectangular subregion),
     |        :py:attr:`PIL.Image.AFFINE` (affine transform),
     |        :py:attr:`PIL.Image.PERSPECTIVE` (perspective transform),
     |        :py:attr:`PIL.Image.QUAD` (map a quadrilateral to a rectangle), or
     |        :py:attr:`PIL.Image.MESH` (map a number of source quadrilaterals
     |        in one operation).
     |      :param data: Extra data to the transformation method.
     |      :param resample: Optional resampling filter.  It can be one of
     |         :py:attr:`PIL.Image.NEAREST` (use nearest neighbour),
     |         :py:attr:`PIL.Image.BILINEAR` (linear interpolation in a 2x2
     |         environment), or :py:attr:`PIL.Image.BICUBIC` (cubic spline
     |         interpolation in a 4x4 environment). If omitted, or if the image
     |         has mode "1" or "P", it is set to :py:attr:`PIL.Image.NEAREST`.
     |      :returns: An :py:class:`~PIL.Image.Image` object.
     |  
     |  transpose(self, method)
     |      Transpose image (flip or rotate in 90 degree steps)
     |      
     |      :param method: One of :py:attr:`PIL.Image.FLIP_LEFT_RIGHT`,
     |        :py:attr:`PIL.Image.FLIP_TOP_BOTTOM`, :py:attr:`PIL.Image.ROTATE_90`,
     |        :py:attr:`PIL.Image.ROTATE_180`, or :py:attr:`PIL.Image.ROTATE_270`.
     |      :returns: Returns a flipped or rotated copy of this image.
     |  
     |  verify(self)
     |      Verifies the contents of a file. For data read from a file, this
     |      method attempts to determine if the file is broken, without
     |      actually decoding the image data.  If this method finds any
     |      problems, it raises suitable exceptions.  If you need to load
     |      the image after using this method, you must reopen the image
     |      file.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  format = None
     |  
     |  format_description = None

    class ImagePointHandler

    class ImageTransformHandler

FUNCTIONS
    alpha_composite(im1, im2)
        Alpha composite im2 over im1.

        :param im1: The first image.
        :param im2: The second image.  Must have the same mode and size as
           the first image.
        :returns: An :py:class:`~PIL.Image.Image` object.

    blend(im1, im2, alpha)
        Creates a new image by interpolating between two input images, using
        a constant alpha.::

            out = image1 * (1.0 - alpha) + image2 * alpha

        :param im1: The first image.
        :param im2: The second image.  Must have the same mode and size as
           the first image.
        :param alpha: The interpolation alpha factor.  If alpha is 0.0, a
           copy of the first image is returned. If alpha is 1.0, a copy of
           the second image is returned. There are no restrictions on the
           alpha value. If necessary, the result is clipped to fit into
           the allowed output range.
        :returns: An :py:class:`~PIL.Image.Image` object.

    coerce_e(value)

    composite(image1, image2, mask)
        Create composite image by blending images using a transparency mask.

        :param image1: The first image.
        :param image2: The second image.  Must have the same mode and
           size as the first image.
        :param mask: A mask image.  This image can can have mode
           "1", "L", or "RGBA", and must have the same size as the
           other two images.

    eval(image, *args)
        Applies the function (which should take one argument) to each pixel
        in the given image. If the image has more than one band, the same
        function is applied to each band. Note that the function is
        evaluated once for each possible pixel value, so you cannot use
        random components or other generators.

        :param image: The input image.
        :param function: A function object, taking one integer argument.
        :returns: An :py:class:`~PIL.Image.Image` object.

    fromarray(obj, mode=None)
        Creates an image memory from an object exporting the array interface
        (using the buffer protocol).

        If obj is not contiguous, then the tobytes method is called
        and :py:func:`~PIL.Image.frombuffer` is used.

        :param obj: Object with array interface
        :param mode: Mode to use (will be determined from type if None)
        :returns: An image memory.

        .. versionadded:: 1.1.6

    frombuffer(mode, size, data, decoder_name='raw', *args)
        Creates an image memory referencing pixel data in a byte buffer.

        This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data
        in the byte buffer, where possible.  This means that changes to the
        original buffer object are reflected in this image).  Not all modes can
        share memory; supported modes include "L", "RGBX", "RGBA", and "CMYK".

        Note that this function decodes pixel data only, not entire images.
        If you have an entire image file in a string, wrap it in a
        **BytesIO** object, and use :py:func:`~PIL.Image.open` to load it.

        In the current version, the default parameters used for the "raw" decoder
        differs from that used for :py:func:`~PIL.Image.fromstring`.  This is a
        bug, and will probably be fixed in a future release.  The current release
        issues a warning if you do this; to disable the warning, you should provide
        the full set of parameters.  See below for details.

        :param mode: The image mode.
        :param size: The image size.
        :param data: A bytes or other buffer object containing raw
            data for the given mode.
        :param decoder_name: What decoder to use.
        :param args: Additional parameters for the given decoder.  For the
            default encoder ("raw"), it's recommended that you provide the
            full set of parameters::

                frombuffer(mode, size, data, "raw", mode, 0, 1)

        :returns: An :py:class:`~PIL.Image.Image` object.

        .. versionadded:: 1.1.4

    frombytes(mode, size, data, decoder_name='raw', *args)
        Creates a copy of an image memory from pixel data in a buffer.

        In its simplest form, this function takes three arguments
        (mode, size, and unpacked pixel data).

        You can also use any pixel decoder supported by PIL.  For more
        information on available decoders, see the section
        **Writing Your Own File Decoder**.

        Note that this function decodes pixel data only, not entire images.
        If you have an entire image in a string, wrap it in a
        :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load
        it.

        :param mode: The image mode.
        :param size: The image size.
        :param data: A byte buffer containing raw data for the given mode.
        :param decoder_name: What decoder to use.
        :param args: Additional parameters for the given decoder.
        :returns: An :py:class:`~PIL.Image.Image` object.

    fromstring(*args, **kw)
        Deprecated alias to frombytes.

        .. deprecated:: 2.0

    getmodebandnames(mode)
        Gets a list of individual band names.  Given a mode, this function returns
        a tuple containing the names of individual bands (use
        :py:method:`~PIL.Image.getmodetype` to get the mode used to store each
        individual band.

        :param mode: Input mode.
        :returns: A tuple containing band names.  The length of the tuple
            gives the number of bands in an image of the given mode.
        :exception KeyError: If the input mode was not a standard mode.

    getmodebands(mode)
        Gets the number of individual bands for this mode.

        :param mode: Input mode.
        :returns: The number of bands in this mode.
        :exception KeyError: If the input mode was not a standard mode.

    getmodebase(mode)
        Gets the "base" mode for given mode.  This function returns "L" for
        images that contain grayscale data, and "RGB" for images that
        contain color data.

        :param mode: Input mode.
        :returns: "L" or "RGB".
        :exception KeyError: If the input mode was not a standard mode.

    getmodetype(mode)
        Gets the storage type mode.  Given a mode, this function returns a
        single-layer mode suitable for storing individual bands.

        :param mode: Input mode.
        :returns: "L", "I", or "F".
        :exception KeyError: If the input mode was not a standard mode.

    init()
        Explicitly initializes the Python Imaging Library. This function
        loads all available file format drivers.

    isImageType(t)
        Checks if an object is an image object.

        .. warning::

           This function is for internal use only.

        :param t: object to check if it's an image
        :returns: True if the object is an image

    merge(mode, bands)
        Merge a set of single band images into a new multiband image.

        :param mode: The mode to use for the output image.
        :param bands: A sequence containing one single-band image for
            each band in the output image.  All bands must have the
            same size.
        :returns: An :py:class:`~PIL.Image.Image` object.

    new(mode, size, color=0)
        Creates a new image with the given mode and size.

        :param mode: The mode to use for the new image.
        :param size: A 2-tuple, containing (width, height) in pixels.
        :param color: What color to use for the image.  Default is black.
           If given, this should be a single integer or floating point value
           for single-band modes, and a tuple for multi-band modes (one value
           per band).  When creating RGB images, you can also use color
           strings as supported by the ImageColor module.  If the color is
           None, the image is not initialised.
        :returns: An :py:class:`~PIL.Image.Image` object.

    open(fp, mode='r')
        Opens and identifies the given image file.

        This is a lazy operation; this function identifies the file, but the
        actual image data is not read from the file until you try to process
        the data (or call the :py:meth:`~PIL.Image.Image.load` method).
        See :py:func:`~PIL.Image.new`.

        :param file: A filename (string) or a file object.  The file object
           must implement :py:meth:`~file.read`, :py:meth:`~file.seek`, and
           :py:meth:`~file.tell` methods, and be opened in binary mode.
        :param mode: The mode.  If given, this argument must be "r".
        :returns: An :py:class:`~PIL.Image.Image` object.
        :exception IOError: If the file cannot be found, or the image cannot be
           opened and identified.

    preinit()
        Explicitly load standard file format drivers.

    register_extension(id, extension)
        Registers an image extension.  This function should not be
        used in application code.

        :param id: An image format identifier.
        :param extension: An extension used for this format.

    register_mime(id, mimetype)
        Registers an image MIME type.  This function should not be used
        in application code.

        :param id: An image format identifier.
        :param mimetype: The image MIME type for this format.

    register_open(id, factory, accept=None)
        Register an image file plugin.  This function should not be used
        in application code.

        :param id: An image format identifier.
        :param factory: An image file factory method.
        :param accept: An optional function that can be used to quickly
           reject images having another format.

    register_save(id, driver)
        Registers an image save function.  This function should not be
        used in application code.

        :param id: An image format identifier.
        :param driver: A function to save images in this format.

DATA
    ADAPTIVE = 1
    AFFINE = 0
    ANTIALIAS = 1
    BICUBIC = 3
    BILINEAR = 2
    CONTAINER = 2
    CUBIC = 3
    DEBUG = 0
    DEFAULT_STRATEGY = 0
    EXTENSION = {'.bmp': 'BMP', '.gif': 'GIF', '.jfif': 'JPEG', '.jpe': 'J...
    EXTENT = 1
    FASTOCTREE = 2
    FILTERED = 1
    FIXED = 4
    FLIP_LEFT_RIGHT = 0
    FLIP_TOP_BOTTOM = 1
    FLOYDSTEINBERG = 3
    HAS_CFFI = True
    HUFFMAN_ONLY = 2
    ID = ['BMP', 'GIF', 'JPEG', 'PPM', 'PNG']
    LINEAR = 2
    MAXCOVERAGE = 1
    MEDIANCUT = 0
    MESH = 4
    MIME = {'GIF': 'image/gif', 'JPEG': 'image/jpeg', 'PNG': 'image/png'}
    MODES = ['1', 'CMYK', 'F', 'I', 'L', 'LAB', 'P', 'RGB', 'RGBA', 'RGBX'...
    NEAREST = 0
    NONE = 0
    NORMAL = 0
    OPEN = {'BMP': (<class PIL.BmpImagePlugin.BmpImageFile>, <function _ac...
    ORDERED = 1
    PERSPECTIVE = 2
    PILLOW_VERSION = '2.4.0'
    QUAD = 3
    RASTERIZE = 2
    RLE = 3
    ROTATE_180 = 3
    ROTATE_270 = 4
    ROTATE_90 = 2
    SAVE = {'BMP': <function _save>, 'GIF': <function _save>, 'JPEG': <fun...
    SEQUENCE = 1
    USE_CFFI_ACCESS = False
    VERSION = '1.1.7'
    WEB = 0
    print_function = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0)...

第二个说的很详细,上面的你看懂了,PIL你也就会用了。上面说的太多,根据网有说比较常用的进行下面的整理。

函数说明

open

open(fp, mode='r')

功能:根据fp文件录取读取图片文件

例子:

from PIL import Image

filename="c:/image/three.jpg"
im=Image.open(filename)
print im.show()
print im

读取并显示图片
就是这个图片
print im 输出图片的一些信息,格式,大小

crop

corp(box)

box=(left, upper, right, and lower)
功能:从左上到右下采取部分图片
例子:

im.crop((110,40,300,300)).show()

getpixel

功能:返回在xy位置处的像素值。

print im.getpixel((220,100))
(242, 223, 208)

太多了,没有耐心整理了,还有几乎都是翻译的。

详情查看链接:
1.http://pillow.readthedocs.org/en/latest/reference/Image.html
2.http://effbot.org/imagingbook/pil-index.htm

上面很多很详细

The Standard Python Library

http://effbot.org/librarybook/

2019-01-08 17:58:53 qq_34471733 阅读数 122

Matlab

比较适合验证算法流程、可以作为验证性工具,广泛应用于研究领域,通过Matlab可以学习图像处理的基本原理、算法,但不适合做工程项目。

OpenCV+C++/Pyhton

OpenCV在实际工程项目中应用比较广泛,是计算机视觉领域的敲门砖,它和C++或者Python结合使用都可以,但数字图像处理的基本原理永远是最重要的。

目前Python比较火,人工智能用的比较多,正好可以借着与OpenCV的结合学习一下。

2018-01-06 14:28:40 qq583357467 阅读数 1870

机器学习、人工智能及图像处理学习提纲

原文
人工智能和机器学习很火,图像处理也很火,在竞争如此激烈的领域中想要取得一定的成绩,就必然要求长期的学习。究竟要学习些什么? 半路出身的我也不是很明确,简要列举几个方面算是自己的学习提纲:

1. 编程技能

两三本编程的书是要熟悉的,包括python、tensorflow、opencv等,后面应用到的编程技能时再做补充

2. 理论基础

机器学习,统计机器学习,deep learning,概率图模型,这些书都需要学么?实话说,我也不知道,反正都得慢慢看

3. 前沿论文

前沿论文必须是一个搞科研的人的茶饭(不是酒肉),看的太少就会营养不良,吃的太多也会消化不了。看论文犹如吃饭一样,每天都看,细嚼慢咽,品出茶饭滋味胜酒肉。

4. 研究价值和社会贡献

机器学习、人工智能处于技术方法层面,而对于做技术的人而言,避而不谈社会价值及研究意义容易形成闭门造车,很难做出亮点,做出新意,也不容易获得项目资助及领导肯定。另外一方面,国家富强也需要研究者在国家政治、经济、文化诸多方面做出贡献(比如经济实力、科技实力、国防实力、综合国力、国防军事、经济能源、人民健康、环境美化、人民对美好生活的向往)。响应国家号召,将机器学习、人工智能学习好、研究透,进一步结合关键性具体问题深入研究应用才是正确的方向。

正是,路漫漫其修远兮,吾将上下而求索。

没有更多推荐了,返回首页