change hsv args

This commit is contained in:
iperov 2022-05-17 13:52:15 +04:00
parent fd0ee234b7
commit b80860cca7
2 changed files with 4 additions and 4 deletions

View file

@ -196,7 +196,7 @@ class TrainingDataGenerator(lib_mp.MPWorker):
ip = lib_img.ImageProcessor(img_aligned_shifted) ip = lib_img.ImageProcessor(img_aligned_shifted)
rnd = np.random rnd = np.random
if rnd.randint(2) == 0: if rnd.randint(2) == 0:
ip.hsv( rnd.randint(0, 360), rnd.uniform(-0.5,0.5), rnd.uniform(-0.5,0.5), mask=lib_sd.random_circle_faded_multi((resolution,resolution), complexity=random_mask_complexity)) ip.hsv( rnd.uniform(0,1), rnd.uniform(-0.5,0.5), rnd.uniform(-0.5,0.5), mask=lib_sd.random_circle_faded_multi((resolution,resolution), complexity=random_mask_complexity))
else: else:
ip.levels( [ [rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),rnd.uniform(0.5,1.5), rnd.uniform(0,0.25),rnd.uniform(0.75,1.0), ], ip.levels( [ [rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),rnd.uniform(0.5,1.5), rnd.uniform(0,0.25),rnd.uniform(0.75,1.0), ],
[rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),rnd.uniform(0.5,1.5), rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),], [rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),rnd.uniform(0.5,1.5), rnd.uniform(0,0.25),rnd.uniform(0.75,1.0),],

View file

@ -466,9 +466,9 @@ class ImageProcessor:
""" """
apply HSV modification for BGR image apply HSV modification for BGR image
h_diff = [-360.0 .. 360.0] h_diff = [-1.0 .. 1.0]
s_diff = [-1.0 .. 1.0]
s_diff = [-1.0 .. 1.0] s_diff = [-1.0 .. 1.0]
v_diff = [-1.0 .. 1.0]
""" """
dtype = self.get_dtype() dtype = self.get_dtype()
self.to_ufloat32() self.to_ufloat32()
@ -481,7 +481,7 @@ class ImageProcessor:
img = img.reshape( (N*H,W,C) ) img = img.reshape( (N*H,W,C) )
h, s, v = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV)) h, s, v = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV))
h = ( h + h_diff ) % 360 h = ( h + h_diff*360.0 ) % 360
s += s_diff s += s_diff
np.clip (s, 0, 1, out=s ) np.clip (s, 0, 1, out=s )