ImageMagick 'convert' command:
Code: Select all
convert 49-0.png -alpha extract 49-0_mask.png
Code: Select all
convert 49-0.png -alpha extract 49-0_mask.png
Hey, that link to AI upscaler looks really promissing, but it doesnt have a interface and thats usually prohibiting me from using it,because Im noob at this.BadLuckBurt wrote: ↑Thu Mar 05, 2020 9:52 pm So, Phedreeke made stuff like this?
ImageMagick 'convert' command:
What happens if this is upscaled with the same algorithm as sprites themselves?Code: Select all
convert 49-0.png -alpha extract 49-0_mask.png
It's fairly automated, I put together a folder with images to be upscaled, this is then run through a number of scripts
1. creates a mask from the image in question
2. antialias the edges of the image, this is then fed to ESRGAN
3. the result of ESRGAN is run through a second script that sharpens, downscales and applies respective game's palette
4. finally, the mask from step 1 is applied to the downscaled image
I antialias the image, followed by upscaling to create the mask, at the end I apply a threshold effect of 127 to make the mask binary
phredreeke wrote: ↑Sat Mar 16, 2019 4:47 amI use SmartSize, which to my understanding uses Bicubic when upscaling and Bilinear when downscaling. I only upscale at integer sizes (actually that's a slight lie with the latest mask, as I omitted 2 pixels on each axis for the last upscale, which I then pad back to the intended size)MasonFace wrote: ↑Tue Mar 12, 2019 2:48 pm You said before that you aren't using a neural network to upscale the masking layer, so are you using interpolation to upscale it? If so, which interpolation model? I'm using GIMP, so I may not have the same interpolation models; all of them produce poor results for upscaling the anti-aliased masking layer. I've even tried using AA, then upscaling 150%, running AA again, upscaling 150%, running AA again, . . . until I reach the target resolution, but it just looks bad.
For antialiasing I actually create a separate layer (I use the color selection tool then use shape-based antialias in PSP, and fill a layer on the inside setting and another layer on the outside setting then take the difference between those two) and use as a mask to soften the underlaying image (the actual mask for the upscaled image).
I believe he recorded his macro in Paint Shop Pro to do all this.phredreeke wrote: ↑Tue Mar 19, 2019 6:11 pm
Anyway, here is the first part of my script. Perhaps someone with enough knowledge of GIMP could make an equivalent script there. (unfortunately no comments because most of it was recorded in one go)
Code: Select all
App.Do( Environment, 'LayerDuplicate', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'NewRasterLayer', { 'General': { 'Opacity': 100, 'Name': r'Raster 1', 'IsVisible': App.Constants.Boolean.true, 'IsTransparencyLocked': App.Constants.Boolean.false, 'LinkSet': 0, 'UseHighlight': App.Constants.Boolean.false, 'PaletteHighlightColor': (255,255,64), 'GroupLink': App.Constants.Boolean.true, 'BlendMode': App.Constants.BlendMode.Normal }, 'BlendRanges': { 'BlendRangeGreen': (0,0,255,255,0,0,255,255), 'BlendRangeRed': (0,0,255,255,0,0,255,255), 'BlendRangeBlue': (0,0,255,255,0,0,255,255), 'BlendRangeGrey': (0,0,255,255,0,0,255,255) }, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'Fill', { 'BlendMode': App.Constants.BlendMode.Normal, 'MatchMode': App.Constants.MatchMode.None, 'Material': { 'Color': (255,255,255), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': r'Material' }, 'UseForground': App.Constants.Boolean.true, 'Opacity': 100, 'Point': (1,1), 'SampleMerged': App.Constants.Boolean.false, 'Tolerance': 0, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,-1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'LayerSetVisibility', { 'Command': App.Constants.ShowCommands.Hide, 'Path': (0,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'SelectAll', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectColorRange', { 'Action': App.Constants.ColorRangeAction.Subtract, 'ReferenceColor': (0,0,0), 'Softness': 1, 'Tolerance': 0, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'ShapeBasedAntialias', { 'AntialiasType': App.Constants.AntialiasType.Inside, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'SelectPromote', { 'KeepSelection': None, 'LayerName': None, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,-2,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'SelectAll', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectColorRange', { 'Action': App.Constants.ColorRangeAction.Subtract, 'ReferenceColor': (0,0,0), 'Softness': 1, 'Tolerance': 0, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'ShapeBasedAntialias', { 'AntialiasType': App.Constants.AntialiasType.Outside, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'SelectPromote', { 'KeepSelection': None, 'LayerName': None, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,-1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'NewRasterLayer', { 'General': { 'Opacity': 100, 'Name': r'Raster 2', 'IsVisible': App.Constants.Boolean.true, 'IsTransparencyLocked': App.Constants.Boolean.false, 'LinkSet': 0, 'UseHighlight': App.Constants.Boolean.false, 'PaletteHighlightColor': (255,255,64), 'GroupLink': App.Constants.Boolean.true, 'BlendMode': App.Constants.BlendMode.Normal }, 'BlendRanges': { 'BlendRangeGreen': (0,0,255,255,0,0,255,255), 'BlendRangeRed': (0,0,255,255,0,0,255,255), 'BlendRangeBlue': (0,0,255,255,0,0,255,255), 'BlendRangeGrey': (0,0,255,255,0,0,255,255) }, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectAll', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'Fill', { 'BlendMode': App.Constants.BlendMode.Normal, 'MatchMode': App.Constants.MatchMode.None, 'Material': { 'Color': (0,0,0), 'Pattern': None, 'Gradient': None, 'Texture': None, 'Identity': r'Material' }, 'UseForground': App.Constants.Boolean.false, 'Opacity': 100, 'Point': (1,1), 'SampleMerged': App.Constants.Boolean.false, 'Tolerance': 0, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'LayerMergeDown', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'LayerProperties', { 'General': { 'Opacity': None, 'Name': None, 'IsVisible': None, 'IsTransparencyLocked': None, 'LinkSet': None, 'UseHighlight': None, 'PaletteHighlightColor': None, 'GroupLink': None, 'BlendMode': App.Constants.BlendMode.Difference }, 'BlendRanges': None, 'Path': (0,0,[],App.Constants.Boolean.false), 'BrightnessContrast': None, 'ChannelMixer': None, 'ColorBalance': None, 'CurveParams': None, 'HSL': None, 'Threshold': None, 'Levels': None, 'Posterize': None, 'Overlay': None, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'LayerMergeDown', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (0,-1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'DeleteLayer', { 'Path': None, 'MergeMask': App.Constants.Boolean.true, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'DeleteLayer', { 'Path': None, 'MergeMask': App.Constants.Boolean.true, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'LayerDuplicate', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'Soften', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'MaskFromImage', { 'CreateMaskFrom': App.Constants.CreateMaskFrom.Luminance, 'InvertMaskData': App.Constants.Boolean.false, 'SourceImage': 0, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'SelectLayer', { 'Path': (1,1,[],App.Constants.Boolean.false), 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Default } }) App.Do( Environment, 'DeleteLayer', { 'Path': None, 'MergeMask': App.Constants.Boolean.true, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } }) App.Do( Environment, 'LayerMergeDown', { 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match } })
Yeah, believe me, this stuff gets out of hand real quick. And KoW knows that better than anyone. I definitely don't blame you.If you dont mind, I dont want to get too involved with creating these masks. What I thought would be just assisting KoW with the last stretch of the paperdoll stuff is quickly ballooning into something else.
ImageMagick is freely available and I never used it before, I just knew it existed. Im figuring out commands by Googling and trial and error and if anyone need help with that I dont mind but I cant commit to create those masks.
So I think what I should do is, have the ESRGANs, use ImageMagick, it will make 90% of the items corectly. Those which are not done corectly I will deal with later.After you've done this the images will have a solid black background that needs to be removed. I used a utility called imagemagick for nearly all of the images, but a few with thinner lines needed manual work with the "magic wand" selection tool in Paint.Net. The imagemagick code I used is as follows:
for %%f in (*.png) do convert %%f -fuzz 10 -transparent rgb(0,0,0) output/%%f
Make sure to add a folder named output next to the file. Any .png in the folder with the bat will be converted, and the results will be found in the output folder.
This will clean up some of the images perfectly. But many defects will result due to automated processes. To clean frayed, pixelated, or otherwise slightly garbled edges, I use a Paint.Net plugin called: AA's_Assistant by dpy.
Now after much editing and Anti-aliasing, you'll have all your images.