<commit_before>"""Routines for analysing images of moles."""


import math

import cv2

import mel.lib.math


def find_mole(frame):
    # look for areas of high saturation, they are likely moles
    img = frame.copy()
    img = cv2.blur(img, (40, 40))
    img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    img = cv2.split(img)[1]
    _, img = cv2.threshold(img, 30, 255, cv2.THRESH_BINARY)
    ringed, stats, _ = mel.lib.moleimaging.process_contours(img, frame)
    return ringed, stats


def calc_hist(image, channel, mask):
    hist = cv2.calcHist(
        [image], [channel], mask, [8], [0, 256])
    hist = [int(x) for x in hist]
    hist_sum = sum(hist)
    hist = [100 * x / hist_sum for x in hist]
    return hist<commit_msg>Fix missing import in mel.lib.moleimaging<commit_after>"""Routines for analysing images of moles."""


import math

import cv2

import mel.lib.image
import mel.lib.math


def find_mole(frame):
    # look for areas of high saturation, they are likely moles
    img = frame.copy()
    img = cv2.blur(img, (40, 40))
    img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    img = cv2.split(img)[1]
    _, img = cv2.threshold(img, 30, 255, cv2.THRESH_BINARY)
    ringed, stats, _ = mel.lib.moleimaging.process_contours(img, frame)
    return ringed, stats


def calc_hist(image, channel, mask):
    hist = cv2.calcHist(
        [image], [channel], mask, [8], [0, 256])
    hist = [int(x) for x in hist]
    hist_sum = sum(hist)
    hist = [100 * x / hist_sum for x in hist]
    return hist
{'fraction_non_alphanumeric': 0.12873258128732581, 'fraction_numerical': 0.035832780358327807, 'mean_word_length': 3.200557103064067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5358464', 'n_tokens_mistral': 593, 'n_tokens_neox': 551, 'n_words': 159}