diff --git a/classifer.py b/classifer.py index f1a286d..b0f2b6b 100755 --- a/classifer.py +++ b/classifer.py @@ -31,6 +31,7 @@ import utils FEATURE_INDEX = [0, 1, 2] delete_columns = 10 # 已弃用 +num_bins = 10 class WoodClass(object): def __init__(self, load_from=None, w=2048, h=12450, n=5000, p1=0.3, pur=0.99999, left_correct=False, single_pick_mode=False, @@ -276,7 +277,7 @@ class WoodClass(object): x = cv2.cvtColor(x, cv2.COLOR_BGR2LAB) x = np.concatenate((x, x_hsv), axis=2) x = np.reshape(x, (x.shape[0]*x.shape[1], x.shape[2])) - hist, bins = np.histogram(x[:, 0], bins=10) + hist, bins = np.histogram(x[:, 0], bins=num_bins) hist = hist[1:] bins = bins[1:] # x = x[np.argsort(x[:, 0])] diff --git a/hist.py b/hist.py index 388234e..b0a7b75 100644 --- a/hist.py +++ b/hist.py @@ -2,7 +2,7 @@ import cv2 import numpy as np -img_path = 'data/data1015/middle/rgb0.png' +img_path = 'data/data1103/dark/rgb20.png' img = cv2.imread(img_path) img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB) x = img.reshape(img.shape[0]*img.shape[1], img.shape[2]) @@ -16,5 +16,5 @@ y = np.zeros((img.shape[0]*img.shape[1], img.shape[2]), dtype=np.uint8) y[:, ] = mean_value #lab转rgb再保存 y = cv2.cvtColor(y.reshape(img.shape[0], img.shape[1], img.shape[2]), cv2.COLOR_LAB2BGR) -cv2.imwrite('3.png', y.reshape(img.shape[0], img.shape[1], img.shape[2])) +cv2.imwrite('5.png', y.reshape(img.shape[0], img.shape[1], img.shape[2]))