Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waifu2x doesn't handle transparency properly #29

Closed
williammalo opened this issue Jun 16, 2015 · 17 comments
Closed

waifu2x doesn't handle transparency properly #29

williammalo opened this issue Jun 16, 2015 · 17 comments

Comments

@williammalo
Copy link

Examples:

Expected Result
good
Actual Result
bad
To get the example image with good transparency, I ran waifu2x on the image over a black background and over a white background and compared the two with a filter. This proves that waifu2x does work properly if the background isn't semi-transparent

Original image:
sapling_spruce-white

@nodegin
Copy link
Contributor

nodegin commented Jun 17, 2015

If I understand correctly you want to keep the edges crispy?
Why you not just resize it with PS / GIMP by Nearest Neighbor?

@williammalo
Copy link
Author

@nodegin that would make the image pixellated :)

@Archeia
Copy link

Archeia commented Jun 23, 2015

This is also an issue for me as well. It was super fun converting old game assets that I had lost files over, but the sadness of making them transparent was :(

@Saren-Arterius
Copy link

I think waifu2x is not good at pixelated image scaling...
Maybe you would want to try 2xSAI?

@PwnicornDev
Copy link

I can confirm this, it doesn't have to do with pixellation in the original.
In the first example, the edges are blurred where they are flanked by transparent areas. In the second example I added a white background prior to upscaling, resulting in perfectly clean edges.

1411945581847 7292df9f-ac9d-40fe-c0aa-e56ea5e29d97
1411945581847_ 6c18f7de-9a8f-4d45-cd52-db186355d56a

@internetakias
Copy link

Not sure if this is worth mentioning, but earlier versions of waifu2x-caffee could produce transparent images with sharp edges.

@PwnicornDev
Copy link

@internetakias Do you know an exact version where it was working? If we can find the commit that broke it, we should be able to solve it easily.

@internetakias
Copy link

@PwnicornDev
1.0.5 is the last version that produced scales with proper transparency.

@internetakias
Copy link

Hey @nagadomi. You haven't replied to this issue yet, so I want to ask you what you think of this and if there's a way to fix it.

@nagadomi
Copy link
Owner

The latest version slightly improves for this issue but still not enough.
I think this issue is difficult to solve in various cases. (semi transparent or fully transparent, for white background color or black background color)
Sorry, I am pending it.

@internetakias
Copy link

I understand. Thanks for replying and keep up the good work!

nagadomi added a commit that referenced this issue Dec 1, 2015
- make border
- scale the alpha channel by waifu2x
- composite
nagadomi added a commit that referenced this issue Dec 1, 2015
Improve alpha channel handling #29
@nagadomi
Copy link
Owner

nagadomi commented Dec 1, 2015

I fixed this issue. try http://waifu2x.udp.jp/

83d9f6de-1d55-4a43-ca9e-9c9da71e9353

@andreili
Copy link

Sory, reopen issue...
Original image with alpha-channel:
01-00-a00-007sek a
Upscaled image (x2, without denoise):
01-00-a00-007sek a
Transparent space become opaque, which increased the size.
The game has a lot of images, and this problem increases its size by 50-60Gb = /

@nagadomi
Copy link
Owner

nagadomi commented Apr 20, 2016

How is waifu2x supposed to do?
I think it is problem of an original image that has unreasonably large transparent area.

EDIT: I understood what you said. I will fix it soon.

@andreili
Copy link

Unfortunately, it is a feature of the original game, and such areas should be.
Under the program - it does not have to process the field with 100% transparency. Now she treats them as a whole, which significantly increases the processing time:

./images/./Event01/01-00/01-00-A01/01-00-A01-015.PNG: 2.3339378833771 sec
./images/./Event01/01-00/01-00-A01/01-00-A01-015SET.A.PNG: 4.6067349910736 sec
./images/./Event01/01-00/01-00-A01/01-00-A01-015SET.B.PNG: 4.6801130771637 sec
./images/./Event01/01-00/01-00-A01/01-00-A01-015SET.C.PNG: 4.6291019916534 sec

(The first - the background, the rest - imposed on the background image with transparency, similar to the above).

@nagadomi
Copy link
Owner

I fixed that file size problem.
alpha_2x2

before fix: 740888 bytes
after fix: 37333 bytes

And, if image has alpha channel, 2x process time is required. alpha channel upscaling with waifu2x improves the upscaling result in some case.
see: https://twitter.com/mhhpnvu/status/673488043735539712

@andreili
Copy link

Yes, the local version has updated and checked.
Thanks for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants