friendblend.processing package

Subpackages

Submodules

friendblend.processing.alpha_blending module

Alpha Blending

friendblend.processing.alpha_blending.alpha_blend(img_l, img_r, bb_l, bb_r)[source]

Performs alpha blending on the images

friendblend.processing.color_correction module

Contains code for color correction of the image. CLAHE - Contrast Limited Adaptive Histogram Equalization

friendblend.processing.color_correction.apply_clahe(img, clip_limit=3.0, n_bins=256, grid=(7, 7))[source]
Parameters:
  • The input image in BGR format

  • The clip limit for contrast limiting

  • Number of bins to divide the image into

  • Grid size to be used while performing adaptive histogram equalization

friendblend.processing.color_correction.clahe(img, clip_limit=3.0, n_bins=256, grid=(7, 7))[source]
  • Divides the image into frames/cells using the grid values passed to the function

  • Creates a separate histogram for each cell/frame after binning the values

  • The histogram equalization mapping for each cell/frame is also generated

  • The contrast of the image is limited by clipping bin values with ‘clip_limit’

  • Adaptive histogram equalization

friendblend.processing.color_correction.rgb2lab(img)[source]

Converts an RGB image to L*a*b* space Implements formulas described at: https://docs.opencv.org/3.4/de/d25/imgproc_color_conversions.html

friendblend.processing.face_body_detection module

Face and body detection

friendblend.processing.face_body_detection.get_body(img, face_bounds)[source]

Calculates the body bounds using face bounds

friendblend.processing.face_body_detection.get_bounds(img)[source]

Calculates and returns face and body bounds Can die in between

friendblend.processing.face_body_detection.get_face(img)[source]

Returns the face bounds Can die in between

friendblend.processing.grab_cut module

Grab Cut

friendblend.processing.grab_cut.crop_fg(fg, bg)[source]

Superimposes cropped foreground from grabcut onto background image

friendblend.processing.grab_cut.filter_mask(mask: numpy.ndarray, fb: Tuple[int, int, int, int]) → numpy.ndarray[source]

Removes components which are not connected to the face bounding box from foreground

friendblend.processing.grab_cut.grab_cut(img_l, img_r, fb_l, boundary=20)[source]
Performs grabcut
  • extracts face from img_l using face bounding boxes

  • blends the two images

friendblend.processing.helpers module

Common functions used multiple times

class friendblend.processing.helpers.DSU(n)[source]

Bases: object

The union-find algorithm

find(i)[source]

Finds the parent of i’th index

union(i, j)[source]

Puts i and j under the same subtree

friendblend.processing.helpers.connected(img: numpy.ndarray) → numpy.ndarray[source]

Connected components, implementing 4-connectivity

friendblend.processing.helpers.draw_box(img, bounding_box)[source]

Draws a bounding box in image

friendblend.processing.helpers.pt_in_box(pt, box)[source]

pt: (x1, y1) box: (x, y, w, h)

returns whether point is within box

friendblend.processing.keypoint module

Contains code for keypoint detection and matching

class friendblend.processing.keypoint.ORB(**kwargs)[source]

Bases: object

Wrapper over opencv ORB

get_descriptors(kps)[source]

Returns ORB descriptors

get_keypoints()[source]

Returns ORB keypoints

friendblend.processing.keypoint.filter_keypoints(box1, box2, kps)[source]

Only returns keypoints which are NOT in box1 or box2

friendblend.processing.keypoint.find_homography(kps1, ds1, kps2, ds2, img1, img2, max_distance=30)[source]

Uses bruteforce matcher with hamming distance to compute homography fails if matches found are less than min_matches

Module contents