예제 #1
0
def resize_image(img, crop=None, scale=None):
    resolution = get_resolution(img)
    if crop:
        img = crop_image(img, crop[0], crop[1])
    if scale:
        img = scale_image(img, scale[0], scale[1])
    return img, resolution
예제 #2
0
def hog_features_at_scale(image, scale):
    image = scale_image(image, scale)
    image = image[400 // scale:, 720 // scale:, ]

    hog_channel_1 = np.array(
        hog_features_for_channel(image, 0, feature_vector=False))
    hog_channel_2 = np.array(
        hog_features_for_channel(image, 1, feature_vector=False))
    hog_channel_3 = np.array(
        hog_features_for_channel(image, 2, feature_vector=False))

    return hog_channel_1, hog_channel_2, hog_channel_3
예제 #3
0
def test_kmedoids(pixels: np.ndarray, k: int) -> Tuple[np.ndarray, np.ndarray]:
    """
    Convenience wrapper for GATech grading.

    :param pixels: A numpy array of image data
    :param k: Number of clusters to use
    :return: A tuple of classes and centroids
    """
    scaled_data = scale_image(pixels)
    kmedoids = KMedoids(k=k)
    kmedoids.fit(scaled_data, verbose=0)
    return kmedoids.clusters, rescale_image(kmedoids.centroids)