Spaces:
Runtime error
Runtime error
import numpy as np | |
import cv2 | |
def pil_cv2_image_converter(image): | |
numpy_image = np.array(image) | |
# Convert to an OpenCV image; notice the COLOR_RGB2BGR flag, which means | |
# that the color is converted from RGB to BGR format. | |
opencv_image = cv2.cvtColor(numpy_image, cv2.COLOR_RGB2BGR) | |
return opencv_image | |
def chi2_distance(histA, histB, eps = 1e-10): | |
# compute the chi-squared distance | |
d = 0.5 * np.sum([((a - b) ** 2) / (a + b + eps) | |
for (a, b) in zip(histA, histB)]) | |
# return the chi-squared distance | |
return d | |
def euclidean_distance(x, y): | |
# compute the Euclidean distance | |
d = np.sqrt(np.sum((x - y) ** 2)) | |
# return the Euclidean distance | |
return d | |
def merge_features(feature1, feature2): | |
""" | |
Combine two feature vectors of color descriptors and LBP. | |
Parameters: | |
color_features (list): List of color descriptor features. | |
lbp_features (list): List of LBP features. | |
Returns: | |
list: Concatenated feature vector. | |
""" | |
combined_features = feature1 + feature2 | |
return combined_features | |