【发布时间】:2021-12-30 09:11:35
【问题描述】:
【问题讨论】:
-
你必须有一个 alpha 通道的蒙版图像。然后模糊蒙版的边缘并使用它代替原始的 Alpha 通道。请参阅我在stackoverflow.com/questions/63001988/… 的回答中的示例
标签: python opencv image-processing python-imaging-library
【问题讨论】:
标签: python opencv image-processing python-imaging-library
import numpy as np
import cv2
# import the image
input_image = cv2.imread('VagcO.png')
# get the number of rows & columns in m & n respectively
n , m = input_image.shape[0], input_image.shape[1]
# copy the image for image processing
output = np.copy(input_image)
# loop on RGB channels
for layer in range(3):
value = 255
# loop for bottom of image only 15 rows pixel
for row in reversed(range(n)[n-15:]):
# loop for every column pixel in that row
for column in range(m):
# checking if every pixel is zero for usualy for background of images
if output[row,column,0]==0 and output[row,column,1]==0 and output[row,column,2]==0:
# skip that pixel
continue
# chaning the value to 255 and decrementing on every iteration
output[row,column,layer] = value
value = value - 2
cv2.imshow('Original', input_image)
# crop the image to apply the bluring filter
cropedImage = output[n-20:, :, :]
mask = cv2.GaussianBlur(mask, (9,9), sigmaX=1, sigmaY=10, borderType = cv2.BORDER_DEFAULT)
# remaning part of image
output = output[:n-20, : , :]
# adding both part into one image
feathredimg = np.concatenate((output, cropedImage), axis=0)
cv2.imshow("Freathred Image", feathredimg)
cv2.waitKey(0)
cv2.destroyAllWindows()
我为给定问题创建了解决方案。看一看。希望这可以帮助! 此代码与给定的示例图像完美配合。 enter image description here
【讨论】: