<commit_before>#!/opt/local/bin/python2.7

import cv2
import Image
import numpy as np
import os
import sys

def morph(kernel, image, iterations = 1):
    for i in range(0, iterations):
        image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel)
        image = cv2.morphologyEx(image, cv2.MORPH_CLOSE, kernel)

    return image

def extractBuildings(file):
    # Define colors
    startColor1 = np.array([174, 174, 217]) # 236, 202, 201
    endColor1 = np.array([213, 212, 255])
    startColor2 = np.array([152, 150, 206]) #171, 172, 230
    endColor2 = np.array([189, 180, 250])

    img = cv2.imread(file)
    color1 = cv2.inRange(img, startColor1, endColor1)
    color2 = cv2.inRange(img, startColor2, endColor2)
    combined = cv2.bitwise_or(color1, color2)

    kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2, 2))
    combined = morph(kernel, combined)

    combined = cv2.bitwise_not(combined)<commit_msg>Refine basemap building color range.<commit_after>#!/opt/local/bin/python2.7

import cv2
import Image
import numpy as np
import os
import sys

def morph(kernel, image, iterations = 1):
    for i in range(0, iterations):
        image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel)
        image = cv2.morphologyEx(image, cv2.MORPH_CLOSE, kernel)

    return image

def extractBuildings(file):
    # Define colors
    startColor1 = np.array([174, 174, 217]) # 236, 202, 201
    endColor1 = np.array([213, 209, 255])
    startColor2 = np.array([152, 150, 206]) #171, 172, 230
    endColor2 = np.array([189, 180, 250])

    img = cv2.imread(file)
    color1 = cv2.inRange(img, startColor1, endColor1)
    color2 = cv2.inRange(img, startColor2, endColor2)
    combined = cv2.bitwise_or(color1, color2)

    kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2, 2))
    combined = morph(kernel, combined)

    combined = cv2.bitwise_not(combined)
{'fraction_non_alphanumeric': 0.1222637479978644, 'fraction_numerical': 0.08969567538707955, 'mean_word_length': 3.7323232323232323, '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': '1373', 'n_tokens_mistral': 790, 'n_tokens_neox': 680, 'n_words': 165}