Skip to main content

No project description provided

Project description

Toolbox to perform image processing.

Libraries

  • Install numpy, scipy, matplotlib, pillow.

Documentation

imgmagic.display.greyscale(x: numpy.ndarray)

Function that converts image into greyscale.
   Parameters:
     x : numpy.ndarray
      Image to convert.
   Returns:
     output : numpy.ndarray
      Returns the greyscale image.

imgmagic.geometric.crop(img:numpy.ndarray, x:Tuple[int], width:int, height:int)

Function that crops an image.
   Parameters:
     img : numpy.ndarray
      Image to crop.
     x : Tuple[int]
      Coordiates of starting point.
     width : int
      Width of the cropped image.
     height : int
      Height of the cropped image.
   Returns:
     output : numpy.ndarray
      Cropped image.

imgmagic.geometric.rotate(img:numpy.ndarray, degree:float)

Function that rotates an image.
   Parameters:
     img : numpy.ndarray
      Image to rotate.
     degree : int
      Angle of rotaion (degrees). This parameter can be positive or negative.
   Returns:
     output : numpy.ndarray
      Rotated image.

imgmagic.geometric.flipping(img:numpy.ndarray)

Function that flips an image.
   Parameters:
     img : numpy.ndarray
      Image to rotate.
   Returns:
     output : numpy.ndarray
      Flipped image.

imgmagic.geometric.scaling(img:numpy.ndarray, scale:float)

Function that scales an image.
   Parameters:
     img : numpy.ndarray
      Image to scale.
     scale : float
      Factor of scaling (ex. 0.5, 1.25, 2...etc).
   Returns:
     output : numpy.ndarray
      Scaled image.

imgmagic.geometric.reverse(img:numpy.ndarray)

Function that reverts an image.
   Parameters:
     img : numpy.ndarray
      Image to reverse.
   Returns:
     output : numpy.ndarray
      Reverted image.

imgmagic.histogram.adjustContrast(img:numpy.ndarray)

Function that performs contrast stretching.
   Parameters:
     img : numpy.ndarray
      Input image.
   Returns:
     output : numpy.ndarray
      Image (with contrat stretching).

imgmagic.histogram.equalization(img:numpy.ndarray)

Function that performs histogram equalization.
   Parameters:
     img : numpy.ndarray
      Input image.
   Returns:
     output : numpy.ndarray
      Image (with equalization).

imgmagic.histogram.negative(img:numpy.ndarray)

Function that performs computes digital negative of an image.
    s = T( r ) = (L – 1) – r
   Parameters:
     img : numpy.ndarray
      Input image.
   Returns:
     output : numpy.ndarray
      Image (negative).

imgmagic.filter.GaussianNoise(img:numpy.ndarray, mean:float, sigma:float)

Function that adds gaussian noise to an image.
   Parameters:
     img : numpy.ndarray
      Input image.
     mean, sigma : float
      Parameters for gaussian distribution.
   Returns:
     output : numpy.ndarray
      Image (with noise).

imgmagic.filter.SaltnPepperNoise(img:numpy.ndarray, prob:float)

Function that adds salt and pepper noise.
   Parameters:
     img : numpy.ndarray
      Input image.
     prob : float
      Probability for salting (ex. 0.01 ...etc).
   Returns:
     output : numpy.ndarray
      Image (with noise).

imgmagic.filter.filtering(img:numpy.ndarray, types:str, mode:str, *args: Tuple[Any])

Function that perfoms filtering on an image.
   Parameters:
     img : numpy.ndarray
      Input image.
     types : {"lowpass", "highpass", "avg", "gauss"}
      Type of filter.
     mode : {"reflect", "constant", "nearest", "mirror", "wrap"}
      Type of padding.
     args : float
      Extra arguments (optional). For instance, it can be:
          n : size for avg filter
   Returns:
     output : numpy.ndarray
      Image (filtered).

imgmagic.filter.sharpening(img:numpy.ndarray, types:str, mode:str)

Function that perfoms sharpening on an image.
   Parameters:
     img : numpy.ndarray
      Input image.
     types : {"laplacian", "sobel", "roberts"}
      Type of filter.
     mode : {"reflect", "constant", "wrap"}
      Type of padding.
   Returns:
     output : numpy.ndarray
      Image (filtered).

imgmagic.filter.crosscorrelation(img:numpy.ndarray, filters:str, sub:numpy.ndarray)

Function that find a subimage in an image.
   Parameters:
     img : numpy.ndarray
      Input image.
     filters : {"laplacian", "sobel", "roberts"}
      Type of filter.
     sub : numpy.ndarray
      Subimage image.
   Returns:
     output : numpy.ndarray
      Image (found).

imgmagic.fourier.ftfiltering(img:numpy.ndarray, filters:str, *args: Tuple[Any])

Function that perfoms sharpening on an image.
   Parameters:
     img : numpy.ndarray
      Input image.
     filters : {"lowpass", "blowpass", "glowpass", "highpass", "bhighpass", "ghighpass", "bandreject", "bandpass", "homomorphic"}
      Type of filter.
     args : float
      Extra arguments (optional). For instance, it can be:
          D0 : cutoff frequency for Ideal filter ("lowpass", "highpass")
          D0, n : cutoff frequency, order for Butterworth filter ("blowpass", "bhighpass")
          sigma : cutoff frequency for Gaussian filter ("glowpass", "ghighpass")
   Returns:
     output : numpy.ndarray
      Image (filtered).

imgmagic.fourier.UnsharpMasking(img:numpy.ndarray, D0:int, k:int)

Function that performs Unsharp Masking and Highboost filtering.
   Parameters:
     img : numpy.ndarray
      Input image.
     k : float
      Parameter:
          k=1 - unsharp masking
          k>1 - highboost filtering
   Returns:
     output : numpy.ndarray
      Image.

imgmagic.fourier.HighFreqEmph(img:numpy.ndarray, D0:int, k1:int, k2:int)

Function that performs High-frequency emphasis.
   Parameters:
     img : numpy.ndarray
      Input image.
     k1, k2 : float
      Parameters:
          k1=1
          k2=1 - unsharp masking
          k2>1 - highboost filtering
   Returns:
     output : numpy.ndarray
      Image.

Example

import imgmagic
import numpy
import matplotlib.image as mpimg
from PIL import Image

filename = "img.jpeg"
img1 = mpimg.imread(filename)
img2 = imgmagic.filter.filtering(img1, "avg", "wrap", 9)

im = Image.fromarray(img2)
im.save("new.jpeg")

see Image Processing toolbox on github.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imgmagic-0.2.3-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file imgmagic-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: imgmagic-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for imgmagic-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 53442eb9e31fd8230b3e741988a25919854ca0569069e21961308afbc4e4453f
MD5 64ba1ba44ad8cbaceb694ae98d9119dc
BLAKE2b-256 1eb9da5157b0b3ede08abdba0aed77456a7f4f6b01bde0b134c3e50aad89c97f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page