Home > Back-end >  How to handle the intersection of the XOR operation
How to handle the intersection of the XOR operation

Time:07-19

Context

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 :

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.

What I've done so far

I created the first part which consist of shifting the pattern of the satin.
Here's the code :
Image Used : result1

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 :

example2


Vs What I get using Photoshop :

example photoshop


Question

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 ?

CodePudding user response:

The fuzzy logic version of the Boolean or operator is the max operator, and that of the and is min.

For XOR, the most logical equivalent is max(x-y, y-x), more efficiently written as abs(x-y). This paper describes two other options, but the absolute difference seems to reproduce the Photoshop effect just fine.

I would thus implement your code as:

xor_result = cv2.absdiff(shift1, shift2)
output = np.minimum(255 - xor_result, apple)
  • Related