上下文
I'm trying to recreate an effect used on photoshop called satin effect, which creates stainy texture by creating a satin texture (or structure) and applying a blur-like effect.
Example :
I think this effect is achieved by using a double shift of the input pattern from which they apply a XOR operation to get the satin pattern (See Image above - Satin Size 0), then I think they apply a gaussian blur while handling the intersection of the XOR operation.
到目前为止我所做的
I created the first part which consist of shifting the pattern of the satin.
Here's the code :
Image Used : apple.png
apple = cv2.imread('apple.png')
apple = cv2.cvtColor(apple, cv2.COLOR_BGR2GRAY)
# User Inputs (Similar to Photoshop)
angle = 41 # angle of the shift
distance = 100 # distance of the shift
angle = np.deg2rad(180-angle)
tx, ty = (distance*np.cos(angle),distance*np.sin(angle))
# Shifting
shift_matrix1 = np.array([[1,0,tx],[0,1,ty]], dtype=np.float32)
shift_matrix2 = np.array([[1,0,-tx],[0,1,-ty]], dtype=np.float32)
shift1 = cv2.warpAffine(apple, shift_matrix1, apple.shape)
shift2 = cv2.warpAffine(apple,shift_matrix2, apple.shape)
# XOR Operation
xor_result = cv2.bitwise_not(cv2.bitwise_and(cv2.bitwise_xor(shift1, shift2), apple))
output = cv2.bitwise_and(xor_result, apple)
这为我们提供了预期结果(similar to what we achieve with photoshop):
Problem :
But the problem emerge when I try to apply the gaussian blur before the XOR operation (Which can be achieved by adding those two lines of code before the XOR operation :
...
shift1 = cv2.GaussianBlur(shift1, (101,101),0)
shift2 = cv2.GaussianBlur(shift2, (101,101),0)
# XOR Operation
xor_result = ...
And her's what I get :
Vs What I get using Photoshop :
问题
So I think that I'm missing an operation to handle the intersection of those 2 shapes (where we got those weird pixels)
So my question is : What operation do you think we should add in order to handle the intersection of the XOR of these two shapes ?