SLIC超像素(opencv中的库)分割后,获取每一块超像素子块并提取颜色特征(颜色矩)
参考:SLIC超像素分割后,怎样获取超像素子块及其掩摸
图像颜色特征提取(颜色直方图,颜色矩)–python
from skimage.feature import hog
import numpy as np
import cv2
####直接复制参考第二个链接中的代码,提取颜色矩###
def color_moments(img):
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# Split the channels - h,s,v
h, s, v = cv2.split(hsv)
# Initialize the color feature
color_feature = []
# N = h.shape[0] * h.shape[1]
# The first central moment - average
h_mean = np.mean(h) # np.sum(h)/float(N)
s_mean = np.mean(s)