mirror of
https://github.com/NanjingForestryUniversity/supermachine-wood.git
synced 2025-11-08 18:23:54 +00:00
bins可调
This commit is contained in:
parent
962f88c65f
commit
cafcd835cb
@ -31,6 +31,7 @@ import utils
|
|||||||
|
|
||||||
FEATURE_INDEX = [0, 1, 2]
|
FEATURE_INDEX = [0, 1, 2]
|
||||||
delete_columns = 10 # 已弃用
|
delete_columns = 10 # 已弃用
|
||||||
|
num_bins = 10
|
||||||
|
|
||||||
class WoodClass(object):
|
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,
|
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 = cv2.cvtColor(x, cv2.COLOR_BGR2LAB)
|
||||||
x = np.concatenate((x, x_hsv), axis=2)
|
x = np.concatenate((x, x_hsv), axis=2)
|
||||||
x = np.reshape(x, (x.shape[0]*x.shape[1], x.shape[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:]
|
hist = hist[1:]
|
||||||
bins = bins[1:]
|
bins = bins[1:]
|
||||||
# x = x[np.argsort(x[:, 0])]
|
# x = x[np.argsort(x[:, 0])]
|
||||||
|
|||||||
4
hist.py
4
hist.py
@ -2,7 +2,7 @@ import cv2
|
|||||||
import numpy as np
|
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.imread(img_path)
|
||||||
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
|
||||||
x = img.reshape(img.shape[0]*img.shape[1], img.shape[2])
|
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
|
y[:, ] = mean_value
|
||||||
#lab转rgb再保存
|
#lab转rgb再保存
|
||||||
y = cv2.cvtColor(y.reshape(img.shape[0], img.shape[1], img.shape[2]), cv2.COLOR_LAB2BGR)
|
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]))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user