Replace living statue and crystal soul graphics with versions that don't have a background
- Also included is details on how this was done, in case someone else can improve on it. - Living statue attack graphic is derived from Exile III.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 47 KiB |
2
rsrc/remove-bg/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
im_error.txt
|
||||
out.png
|
19
rsrc/remove-bg/apply-alpha.fx
Normal file
@@ -0,0 +1,19 @@
|
||||
aval=u[1]*255;
|
||||
bval=u[2]*255;
|
||||
|
||||
i==21&&j==8 ? debug(aval) : 1;
|
||||
i==21&&j==8 ? debug(bval) : 1;
|
||||
|
||||
dist=bval-aval;
|
||||
|
||||
i==21&&j==8 ? debug(dist) : 1;
|
||||
|
||||
op=u[0].p{i,j}.a;
|
||||
|
||||
i==21&&j==8 ? debug(op) : 1;
|
||||
|
||||
mdist=op==0 ? 0 : dist/op;
|
||||
|
||||
i==21&&j==8 ? debug(mdist) : 1;
|
||||
|
||||
mdist/255
|
BIN
rsrc/remove-bg/back.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
49
rsrc/remove-bg/calc-alpha.fx
Normal file
@@ -0,0 +1,49 @@
|
||||
rback=int(u[1].p{i,j}.r*255);
|
||||
gback=int(u[1].p{i,j}.g*255);
|
||||
bback=int(u[1].p{i,j}.b*255);
|
||||
|
||||
i==21&&j==8 ? debug(rback) : 1;
|
||||
i==21&&j==8 ? debug(gback) : 1;
|
||||
i==21&&j==8 ? debug(bback) : 1;
|
||||
|
||||
rmain=int(u[2].p{i,j}.r*255);
|
||||
gmain=int(u[2].p{i,j}.g*255);
|
||||
bmain=int(u[2].p{i,j}.b*255);
|
||||
|
||||
i==21&&j==8 ? debug(rmain) : 1;
|
||||
i==21&&j==8 ? debug(gmain) : 1;
|
||||
i==21&&j==8 ? debug(bmain) : 1;
|
||||
|
||||
rdiff=rmain - rback;
|
||||
gdiff=gmain - gback;
|
||||
bdiff=bmain - bback;
|
||||
|
||||
i==21&&j==8 ? debug(rdiff) : 1;
|
||||
i==21&&j==8 ? debug(gdiff) : 1;
|
||||
i==21&&j==8 ? debug(bdiff) : 1;
|
||||
|
||||
rgoal=rdiff > 0 ? 255 : 0;
|
||||
ggoal=gdiff > 0 ? 255 : 0;
|
||||
bgoal=bdiff > 0 ? 255 : 0;
|
||||
|
||||
i==21&&j==8 ? debug(rgoal) : 1;
|
||||
i==21&&j==8 ? debug(ggoal) : 1;
|
||||
i==21&&j==8 ? debug(bgoal) : 1;
|
||||
|
||||
rgd=rgoal - rback;
|
||||
ggd=ggoal - gback;
|
||||
bgd=bgoal - bback;
|
||||
|
||||
i==21&&j==8 ? debug(rgd) : 1;
|
||||
i==21&&j==8 ? debug(ggd) : 1;
|
||||
i==21&&j==8 ? debug(bgd) : 1;
|
||||
|
||||
ro=rgd == 0 ? 0 : rdiff / rgd;
|
||||
bo=bgd == 0 ? 0 : bdiff / bgd;
|
||||
go=ggd == 0 ? 0 : gdiff / ggd;
|
||||
|
||||
i==21&&j==8 ? debug(ro) : 1;
|
||||
i==21&&j==8 ? debug(go) : 1;
|
||||
i==21&&j==8 ? debug(bo) : 1;
|
||||
|
||||
max(ro,max(go,bo))
|
BIN
rsrc/remove-bg/final.xcf
Normal file
BIN
rsrc/remove-bg/fore.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
rsrc/remove-bg/mask.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
41
rsrc/remove-bg/remove-bg.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# EXPLANATION
|
||||
#############
|
||||
#
|
||||
# This script was used to strip out the backgrounds from the living statue
|
||||
# and crystal soul monster graphics. It takes as input three images:
|
||||
#
|
||||
# 1. back.png contains the backgrounds to be stripped out.
|
||||
# 2. fore.png contains the original images.
|
||||
# 3. mask.png contains black pixels where the original image should be assumed opaque.
|
||||
#
|
||||
# The actual magic that does this is contained in the two .fx scripts
|
||||
# included in this directory.
|
||||
#
|
||||
# The script produces out.png containing the images with the background removed.
|
||||
# Overall it works quite well; the regular crystal soul (normal and attack graphics)
|
||||
# and the non-attacking living statue look pretty good with no additional
|
||||
# manual adjustment. The other two crystal souls require a little noise removal,
|
||||
# and the living statue attacks still require quite a bit of editing to get
|
||||
# a usable result. Also, though the crystal soul attack looked pretty good,
|
||||
# I used GIMP's levels tool to make it look closer to the original.
|
||||
# (Red down to 240, Green up to 80, Blue up to 80, Alpha down to 230)
|
||||
#
|
||||
# As might be obvious from the below commands, running this script
|
||||
# requires that ImageMagick is installed.
|
||||
#
|
||||
# Note that this script is not at all generic. If you wanted to use it
|
||||
# on other images you would at minimum have to edit the canvas size
|
||||
# specified in the command.
|
||||
#
|
||||
|
||||
convert \
|
||||
-size 113x148 canvas:white -alpha set \
|
||||
back.png fore.png -channel A -fx "@calc-alpha.fx" \
|
||||
back.png fore.png -channel RGB -fx "@apply-alpha.fx" \
|
||||
intermediate.png 2>| im_error.txt
|
||||
|
||||
convert intermediate.png fore.png mask.png -composite out.png
|
||||
|
||||
rm intermediate.png
|