unprompted icon indicating copy to clipboard operation
unprompted copied to clipboard

Txt2mask padding dilate

Open credman0 opened this issue 2 years ago • 2 comments

(This is on top of my previous pr that fixes the rgba txt2mask error, otherwise I can't run anything)

I tried for a bit to fix the padding in txt2mask, but conceptually I don't think that the way that it was working (a resize and a crop) is actually how you need it to work to properly pad the mask. Since we have opencv anyway, this pr changes it to a dilate on the mask, which is closer to padding pixels around the alpha areas.

It isn't perfect, since a dilate loses a lot of the definition of the mask. Probably what we actually want is to threshold a distance map which I believe will give us a better result, but it's at the very least more than I want to get into tonight.

credman0 avatar Dec 26 '22 06:12 credman0

Oh and this effectively addresses #37

credman0 avatar Dec 26 '22 06:12 credman0

conceptually I don't think that the way that it was working (a resize and a crop) is actually how you need it to work to properly pad the mask.

Yeah, no kidding! I must have been pretty tired when I implemented padding. :) It resizes the canvas from the center, rather than from the origin of the masked area(s).

It sounds like dilate is a much better approach. I'll give your code a spin and probably merge it in the next update. A bit of quality loss is likely okay--at least for the time being--as the A1111 inpainting feature is pretty forgiving when it comes to mask imperfections.

Thank you!

ThereforeGames avatar Dec 29 '22 08:12 ThereforeGames