feat
fix 超分异常
This commit is contained in:
@@ -85,39 +85,6 @@ class Painting(object):
|
||||
pattern[0, 0, 2] = int(R)
|
||||
return pattern
|
||||
|
||||
@staticmethod
|
||||
def gradient(image, angle_degrees, start_color, end_color):
|
||||
height, width = image.shape[0], image.shape[1]
|
||||
|
||||
# 创建一个空白的图像
|
||||
gradient_image = np.zeros((height, width, 3), dtype=np.uint8)
|
||||
|
||||
# 将角度限制在 0 到 360 度之间
|
||||
angle_degrees = np.clip(angle_degrees, 0, 360)
|
||||
|
||||
# 将角度转换为弧度
|
||||
angle_radians = np.radians(angle_degrees)
|
||||
|
||||
# 计算渐变的方向
|
||||
dx = np.cos(angle_radians)
|
||||
dy = np.sin(angle_radians)
|
||||
|
||||
# 创建网格
|
||||
x_grid, y_grid = np.meshgrid(np.arange(width), np.arange(height))
|
||||
|
||||
# 计算每个像素在渐变方向上的位置
|
||||
distance_along_gradient = (x_grid * dx + y_grid * dy) / np.sqrt(dx ** 2 + dy ** 2)
|
||||
|
||||
# 计算渐变的权重
|
||||
weight = np.clip(distance_along_gradient / max(width, height), 0, 1)
|
||||
|
||||
# 计算渐变的颜色
|
||||
gradient_image[:, :, 0] = (1 - weight) * start_color[0] + weight * end_color[0]
|
||||
gradient_image[:, :, 1] = (1 - weight) * start_color[1] + weight * end_color[1]
|
||||
gradient_image[:, :, 2] = (1 - weight) * start_color[2] + weight * end_color[2]
|
||||
|
||||
return gradient_image
|
||||
|
||||
|
||||
@PIPELINES.register_module()
|
||||
class PrintPainting(object):
|
||||
@@ -147,8 +114,8 @@ class PrintPainting(object):
|
||||
resized_source = image.resize(new_size)
|
||||
resized_source_mask = mask.resize(new_size)
|
||||
|
||||
rotated_resized_source = resized_source.rotate(result['print']['print_angle_list'][i])
|
||||
rotated_resized_source_mask = resized_source_mask.rotate(result['print']['print_angle_list'][i])
|
||||
rotated_resized_source = resized_source.rotate(-result['print']['print_angle_list'][i])
|
||||
rotated_resized_source_mask = resized_source_mask.rotate(-result['print']['print_angle_list'][i])
|
||||
|
||||
source_image_pil = Image.fromarray(cv2.cvtColor(print_background, cv2.COLOR_BGR2RGB))
|
||||
source_image_pil_mask = Image.fromarray(cv2.cvtColor(mask_background, cv2.COLOR_BGR2RGB))
|
||||
@@ -268,8 +235,8 @@ class PrintPainting(object):
|
||||
resized_source = image.resize(new_size)
|
||||
resized_source_mask = mask.resize(new_size)
|
||||
|
||||
rotated_resized_source = resized_source.rotate(result['element']['element_angle_list'][i])
|
||||
rotated_resized_source_mask = resized_source_mask.rotate(result['element']['element_angle_list'][i])
|
||||
rotated_resized_source = resized_source.rotate(-result['element']['element_angle_list'][i])
|
||||
rotated_resized_source_mask = resized_source_mask.rotate(-result['element']['element_angle_list'][i])
|
||||
|
||||
source_image_pil = Image.fromarray(cv2.cvtColor(print_background, cv2.COLOR_BGR2RGB))
|
||||
source_image_pil_mask = Image.fromarray(cv2.cvtColor(mask_background, cv2.COLOR_BGR2RGB))
|
||||
|
||||
Reference in New Issue
Block a user