dippykit package

Module contents

Common import for all dippykit functions

Importing

Recommended techniques for importing this library are the following:

  • For a default import, use:
    >>> import dippykit as dip
    >>> # Refer to all functions using the dip.function() syntax, e.g.:
    >>> dip.window_2d(4, 'r', dim=2)
    array([[0.  , 0.  , 0.  , 0.  ],
           [0.  , 0.25, 0.25, 0.  ],
           [0.  , 0.25, 0.25, 0.  ],
           [0.  , 0.  , 0.  , 0.  ]])
    
  • For a static import, use:
    >>> from dippykit import *
    >>> # Refer to all functions using the function() syntax, e.g.:
    >>> window_2d(4, 'r', dim=2)
    array([[0.  , 0.  , 0.  , 0.  ],
           [0.  , 0.25, 0.25, 0.  ],
           [0.  , 0.25, 0.25, 0.  ],
           [0.  , 0.  , 0.  , 0.  ]])
    

New Types

In the documentation for this library there are two new types used. These are NumericType and ShapeType.

NumericType is an alias for the union of int and float, and as such represents values that can be either integers or floating point numbers.

ShapeType is an alias for the union of NumericType and Tuple[NumericType, NumericType]. In effect, ShapeType is something that could be logically construed as the dimensions of some rectangle. For single-element or scalar arguments, the shape is square. Integer arguments describe the absolute size of the rectangle, whereas floating point arguments describe the size of the rectangle relative to some other rectangle. For example, when specifying the to crop a (256, 256) region from an image of size (512, 512), one could specify a shape of 256, 0.5, (256, 256), or (0.5, 0.5).

Aliases to External Packages

Some functions available through this library are merely aliases for functions provided by external packages. This is done for simplicity and ease of student experience. These aliases, along with links to their referenced functions’ documentation pages, are listed below:

dippykit.medianBlur(src, ksize[, dst]) → dst

. @brief Blurs an image using the median filter. . . The function smoothes an image using the median filter with the f$texttt{ksize} times . texttt{ksize}f$ aperture. Each channel of a multi-channel image is processed independently. . In-place operation is supported. . . @note The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes . . @param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be . CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. . @param dst destination array of the same size and type as src. . @param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 … . @sa bilateralFilter, blur, boxFilter, GaussianBlur

dippykit.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]]) → dst

. @brief Resizes an image. . . The function resize resizes the image src down to or up to the specified size. Note that the . initial dst type or size are not taken into account. Instead, the size and type are derived from . the src,`dsize`,`fx`, and fy. If you want to resize src so that it fits the pre-created dst, . you may call the function as follows: . @code . // explicitly specify dsize=dst.size(); fx and fy will be computed from that. . resize(src, dst, dst.size(), 0, 0, interpolation); . @endcode . If you want to decimate the image by factor of 2 in each direction, you can call the function this . way: . @code . // specify fx and fy and let the function compute the destination image size. . resize(src, dst, Size(), 0.5, 0.5, interpolation); . @endcode . To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to . enlarge an image, it will generally look best with c#INTER_CUBIC (slow) or #INTER_LINEAR . (faster but still looks OK). . . @param src input image. . @param dst output image; it has the size dsize (when it is non-zero) or the size computed from . src.size(), fx, and fy; the type of dst is the same as of src. . @param dsize output image size; if it equals zero, it is computed as: . f[texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}f] . Either dsize or both fx and fy must be non-zero. . @param fx scale factor along the horizontal axis; when it equals 0, it is computed as . f[texttt{(double)dsize.width/src.cols}f] . @param fy scale factor along the vertical axis; when it equals 0, it is computed as . f[texttt{(double)dsize.height/src.rows}f] . @param interpolation interpolation method, see #InterpolationFlags . . @sa warpAffine, warpPerspective, remap