Open Maelstrom2014 opened 1 month ago
update and tell me if it is better, i added blur and erosion
update and tell me if it is better, i added blur and erosion Great!
I added a PROPAINTER node to inpaint gaps (alpha channel output from your node) between layers. It great, but I need more.
You see jittering or interpolation problemes when moving a layer to new position? I tried to add interpolation in your code when you resize images. But I think its a problems when picture is translated to offset. Integer Pixel coodinates seems to be not precise and causes juttering. What you think, how to make it? I tried to upscale image, but it not helps much. It need some kind of interpolation to pase image to new non interer position.
here is a picture with explonation what i mean: https://www.researchgate.net/figure/Interpolation-on-an-integer-grid_fig1_228855328
More example of "jittering"
found a working function for translating for smooth translation to float number. Im new for commiting code, If i found how to implement it, will write.
height, width, colors=img.shape
#x, y - move image to x (horizontal) and y pixels (can be float)
T= np.array([[1,0,x],[0,1,y]], dtype=np.float32)
img_trans=cv2.warpAffine(img, T, (width, height))
Yes I found. You need to change: in: def apply_perspective_transformation fuction lines:
# translated_mask = self.translate_layer(layer_rgba,tx_offset,ty_offset)
tx_offset_float=(tx * parallax_factor)
ty_offset_float=(ty * parallax_factor)
print(f'tx={tx_offset_float},ty={ty_offset_float}')
T= np.array([[1,0,tx_offset_float],[0,1,ty_offset_float]], dtype=np.float32)
(height, width) = layer_rgba.shape[:2]
translated_mask=cv2.warpAffine(layer_rgba, T, (width, height))
and
#translated_mask = self.cv2_clipped_zoom(translated_mask, z)
translated_mask = cv2.resize(translated_mask, None, fx=z, fy=z)](url)
your lines are commented.
And averything will be smooth zoomed and transtated! I dont know, yet, how to make a pull commit, when I learn, I'll do it.
Here is an example with gray artifact on masks border: https://ibb.co/R0S3BxV I think alpha mask need to be blured a little.