lltcggie / waifu2x-caffe

waifu2xのCaffe版
MIT License
8.08k stars 839 forks source link

BMP file outputs come out with a modified alpha channel #50

Closed FlatCell closed 8 years ago

FlatCell commented 8 years ago

So i tried do Magnify a bunch of .bmp files but the output comes out with a messed up alpha channel. example settings Just wanted to say thanks in advance and keep up the good work!

lltcggie commented 8 years ago

再現しないので、Input.bmpをアップロードしていただけないでしょうか? よろしくお願いします。

FlatCell commented 8 years ago

Sure here is the link to the file: https://drive.google.com/file/d/0Bweq4bg_RcmCNTVoS0stVEl0VGM/view?usp=sharing

nagadomi commented 8 years ago

ImageMagick/GraphicsMagick has the same problem. But it seems that this is browser/viewer side bug. the result of waifu2x-caffe is correct.

R channel: r

G channel: g

B channel: b

A channel: a

R+G+B: rgb

R+G+B+A: rgba

input.bmp.txt

nagadomi commented 8 years ago

BMP3 does not allow transparency http://www.imagemagick.org/discourse-server/viewtopic.php?t=28733#p127820

Maybe browser/viewer follows the above specification.

FlatCell commented 8 years ago

I use gimp and gimp doesn't even detect an Alpha channel in any of those but I installed Photoshop just too check and yeah the output is indeed correct, just the preview has changed. But I found another weird thing. This is the input, notice that "smudge" of color around the character. input output 2

This is the Output, this is the reason why I thought it was a problem with Alpha channel. But after opening the images above in Photoshop the alpha channel is indeed correct but the color channel's aren't.

lltcggie commented 8 years ago

@nagadomi さんが書いてくださったとおり、このソフト自体は意図した動作をしています。 また、完全に透明なピクセル(アルファ値が0)のある画像を変換すると、周りにノイズのようなものが乗るのは仕様です。 処理の都合上、不透明な箇所と透明な箇所の境界を引き延ばす必要があります。 さらに、処理の最初でRGBとAを掛けることにより、完全に透明なピクセルの値を0にしています。 なので、変換を行うとアルファ値が0のピクセルの内容は失われます。 仕様として「アルファ値が0のピクセルの内容は不定になる」と考えてください。

nagadomi commented 8 years ago

waifu2x-caffe and waifu2x(http://waifu2x.udp.jp) will break the RGB pixels in 100% transparent area. The behavior is by current design.

FlatCell commented 8 years ago

Ok thanks for all the info, I'll close the issue since it's not really an issue at all. Keep up the good work!