Fictiverse / ComfyUI_Fictiverse

ComfyUI Fictiverse custom nodes
Apache License 2.0
7 stars 2 forks source link

"Display Image with depth". ARTIFACTS on mask borders. #3

Open Maelstrom2014 opened 1 month ago

Maelstrom2014 commented 1 month ago

Here is an example with gray artifact on masks border: https://ibb.co/R0S3BxV I think alpha mask need to be blured a little.

Fictiverse commented 1 month ago

update and tell me if it is better, i added blur and erosion

Maelstrom2014 commented 2 weeks ago

update and tell me if it is better, i added blur and erosion Great!

https://github.com/Fictiverse/ComfyUI_Fictiverse/assets/10183119/ea98381c-47c4-4295-8092-e0a86d540366

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

Maelstrom2014 commented 2 weeks ago

More example of "jittering"

https://github.com/Fictiverse/ComfyUI_Fictiverse/assets/10183119/592b9305-de5d-4092-9b46-9aa48ec8198a

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))
Maelstrom2014 commented 1 week ago

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.