File size: 1,083 Bytes
ac1c6ae
 
 
 
 
 
 
 
 
53f6094
 
 
 
 
 
 
 
 
 
 
 
 
 
e4ec374
83942d1
 
e4ec374
83942d1
 
 
 
 
 
 
 
 
e4ec374
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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