Python package grouping together common useful functions and operations.
Project description
Imagerie
Lightweight python package grouping together useful computer vision functions and operations
This package was initially created for myself to extract some of the most useful important functions,
from packages like scipy
, skimage
, etc...
This was done in order to expose all these very useful computer vision functions,
and be able to use them in a Serverless environment.
Documentation
Prerequisites
This package only supports python3
today.
Only tested on python3.6
and python3.7
Installation
Install using pip pip install imagerie
.
Functions
imagerie.get_rotation(pt1, pt2)
Returns the rotation value in degrees between 2 (x,y) points.
imagerie.order_points(points)
You've guessed it, this function simply sorts a list of 4 [x, y] coordinates in a clockwise manner, starting from the top-left.
imagerie.remove_lonely_small_objects(grayscale)
This function removes small white objects from a binary mask.
imagerie.remove_smaller_objects(grayscale)
Finds all contours and removes them all except the biggest one.
imagerie.biggest_contour(grayscale)
Finds and retrieves the biggest contour from a grayscale image.
imagerie.get_biggest_contour(contours)
Simply retrieves and returns the biggest contour from a given list of contours.
imagerie.closest_point(point: tuple, points)
Returns the closest (x, y) point from a given list of (x, y) points/coordinates.
imagerie_lite.midpoint(ptA, ptB)
Calculates the X,Y middle points from provided 2 points.
imagerie_lite.line_intersection(line1: tuple, line2: tuple)
Returns the intersection point between two lines.
imagerie.get_corners(grayscale, middle_points=False, centroid=False, max_corners=4, quality_level=0.01, min_distance=15)
Returns the (x, y) coordinates of the 4 corners of a rectangular shaped object from binary mask by default.
However, you can also calculate the top and bottom middle coordinates by providing middle_points=True
.
And by providint centroid=True
, you can get the (x, y) coordinates of the center.
imagerie.warp_perspective(image, src_pts: list, dst_pts: list)
Performs a cv2.warpPerspective()
operation and expects 2 lists of (x, y) corner points of the source
and destination image.
imagerie.warp_homography(image, src_pts: list, dst_pts: list, method=cv2.RANSAC, reproj_threshold=5.0)
Performs a cv2.warpPerspective()
operation after cv2.findHomography()
.
imagerie.image_composite_with_mask(to_add: PIL.Image.Image, destination: PIL.Image.Image, mask: PIL.Image.Image)
Combines the to_add
and destination
images, to_add
image will be added on top of destination
image
and only the white area from the mask
image will be retained from to_add
image.
imagerie.combine_two_images_with_mask(background_img, foreground_img, mask)
Combines the images with the help of the provided mask.
Note that only the white area of the mask will be selected from the foreground_img
.
imagerie.prepare_for_prediction_single(img, shape=(768, 768), as_array=True)
Loads and resizes a single image to a given shape (default: 768, 768) and returns it by default as a numpy array.
imagerie.prepare_for_prediction(imgs, shape=(768, 768))
Does the same thing as imagerie.prepare_for_prediction_single
but for multiple images.
imagerie.fill_holes(gray_img: ndarray, min=200, max=255)
Fills black pixel holes that reside inside of a binary object.
min
represents thethresh
used incv2.threshold(gray, thresh=200, ...)
.
max
represents themaxval
used incv2.threshold(gray, maxval=255, ...)
.
imagerie.img_as_uint(img)
Converts image to 16 bit unsigned integer format.
imagerie.img_as_float(img)
Convert an image to floating point format.
imagerie.normalize_binary_img(img: np.ndarray)
Very useful when re-converting a predicted binary mask img to original grayscale format.
Credits
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file imagerie-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: imagerie-0.0.11-py3-none-any.whl
- Upload date:
- Size: 48.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb7218c114ae57d29c562a26ccf56af378f27814d5029d4844ee7c82d6db9ef1 |
|
MD5 | ac77b1992d36ccc1441874bd743a25b0 |
|
BLAKE2b-256 | ed065a2993721ddd7d02a45ba414636355e88a6be1ef7158867257fa014bac3c |