Metadata-Version: 2.1
Name: imgmagic
Version: 0.2.1
Summary: UNKNOWN
Home-page: UNKNOWN
License: UNKNOWN
Platform: UNKNOWN
Description-Content-Type: text/markdown
Requires-Dist: numpy (>=1.23.4)
Requires-Dist: scipy (>=1.11.4)
Requires-Dist: matplotlib (>=3.5.1)
Requires-Dist: pillow (>=9.0.1)
Requires-Dist: protobuf (<4)

# Image Processing
Toolbox to perform image processing.

### Libraries
* Install numpy, scipy, matplotlib, pillow.

### Documentation
##### imgmagic.display.greyscale(x: numpy.ndarray)
```bash
Function that converts image into greyscale.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **x : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image to convert.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Returns the greyscale image.
```

##### imgmagic.geometric.crop(img:numpy.ndarray, x:Tuple[int], width:int, height:int)
 Function that crops an image.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image to crop.
&emsp;&emsp;&emsp;&emsp; **x : Tuple[int]**
&emsp;&emsp;&emsp;&emsp;&emsp; Coordiates of starting point.
&emsp;&emsp;&emsp;&emsp; **width : int**
&emsp;&emsp;&emsp;&emsp;&emsp; Width of the cropped image.
&emsp;&emsp;&emsp;&emsp; **height : int**
&emsp;&emsp;&emsp;&emsp;&emsp; Height of the cropped image.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Cropped image.

    
##### imgmagic.geometric.rotate(img:numpy.ndarray, degree:float)
Function that rotates an image.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image to rotate.
&emsp;&emsp;&emsp;&emsp; **degree : int**
&emsp;&emsp;&emsp;&emsp;&emsp; Angle of rotaion (degrees). This parameter can be positive or negative.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Rotated image.

##### imgmagic.geometric.flipping(img:numpy.ndarray)
Function that flips an image.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image to rotate.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Flipped image.

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

##### imgmagic.geometric.reverse(img:numpy.ndarray)
Function that reverts an image.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image to reverse.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Reverted image.

##### imgmagic.histogram.adjustContrast(img:numpy.ndarray)
Function that performs contrast stretching.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image (with contrat stretching).

##### imgmagic.histogram.equalization(img:numpy.ndarray)
Function that performs histogram equalization.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image (with equalization).

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

##### imgmagic.filter.GaussianNoise(img:numpy.ndarray, mean:float, sigma:float)
Function that adds gaussian noise to an image.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp;&emsp;&emsp; **mean, sigma : float**
&emsp;&emsp;&emsp;&emsp;&emsp; Parameters for gaussian distribution.
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image (with noise).

##### imgmagic.filter.SaltnPepperNoise(img:numpy.ndarray, prob:float)
Function that adds salt and pepper noise.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp;&emsp;&emsp; **prob : float**
&emsp;&emsp;&emsp;&emsp;&emsp; Probability for salting (ex. 0.01 ...etc).
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image (with noise).

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


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

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

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


##### imgmagic.fourier.UnsharpMasking(img:numpy.ndarray, D0:int, k:int)
Function that performs Unsharp Masking and Highboost filtering.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp;&emsp;&emsp; **k : float**
&emsp;&emsp;&emsp;&emsp;&emsp; Parameter:
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; k=1 - unsharp masking
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; k>1 - highboost filtering
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image.


##### imgmagic.fourier.HighFreqEmph(img:numpy.ndarray, D0:int, k1:int, k2:int)
Function that performs High-frequency emphasis.
&emsp;&emsp; **Parameters**:
&emsp;&emsp;&emsp;&emsp; **img : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Input image.
&emsp;&emsp;&emsp;&emsp; **k1, k2 : float**
&emsp;&emsp;&emsp;&emsp;&emsp; Parameters:
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; k1=1
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; k2=1 - unsharp masking
&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; k2>1  - highboost filtering
&emsp;&emsp; **Returns**:
&emsp;&emsp;&emsp;&emsp; **output : numpy.ndarray**
&emsp;&emsp;&emsp;&emsp;&emsp; Image.


### Example
```bash
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](https://github.com/kkf017/Image-Processing-toolbox-).



