Added program files

This commit is contained in:
Thelie 2022-01-05 23:58:56 +01:00
parent 6fcf8db749
commit 68a674f86b
5 changed files with 288 additions and 0 deletions

6
color_palette.txt Normal file
View file

@ -0,0 +1,6 @@
red
orange
yellow
pink
green
SaddleBrown

22
color_palette_dither.sh Normal file
View file

@ -0,0 +1,22 @@
#!/bin/sh
img=$1
palette=$2
colors=$(cat $palette)
COUNTER=1
magick convert "$img" -fuzz 99% -fill black +opaque white -fill black -opaque white /tmp/img_out_d0.png
for color in $colors
do
echo "Creating image with counter ${COUNTER}."
./get_color_part.sh "$img" "$color" "7c${COUNTER}"
magick composite -compose plus \
"/tmp/img_out_d$((COUNTER-1)).png" \
"img_out_${color}.png" \
"/tmp/img_out_d$((COUNTER)).png"
COUNTER=$((COUNTER+1))
done
magick convert "/tmp/img_out_d$((COUNTER-1)).png" img_out_dithered_full.gif

6
color_palette_sky.txt Normal file
View file

@ -0,0 +1,6 @@
RoyalBlue
blue4
CornflowerBlue
pink
orange
wheat

15
get_color_part.sh Normal file
View file

@ -0,0 +1,15 @@
#!/bin/sh
img=$1
color=$2
dither=$3
magick convert "$img" -fuzz 30% -fill black +opaque "$color" -fill white -opaque "$color" /tmp/img_block.png
magick convert "$img" -fuzz 1% -fill black +opaque white -fill white -opaque white /tmp/img_white_block.png
magick composite /tmp/img_block.png -compose add /tmp/img_white_block.png /tmp/img_full_block.png
magick convert "$img" -fuzz 100% -fill "$color" -opaque "$color" /tmp/img_col.png
magick composite "$img" -compose difference /tmp/img_col.png /tmp/img_diff.png
magick convert /tmp/img_diff.png -set colorspace Gray -separate -average -negate /tmp/img_mask.png
magick composite /tmp/img_mask.png -compose multiply /tmp/img_full_block.png /tmp/img_val.png
magick convert /tmp/img_val.png -negate -ordered-dither "$dither" -negate /tmp/img_val_dithered.png
magick composite /tmp/img_val_dithered.png -compose multiply /tmp/img_col.png img_out_"$color".png

239
thresholds.xml Normal file
View file

@ -0,0 +1,239 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE thresholds [
<!ELEMENT thresholds (threshold)+>
<!ATTLIST thresholds xmlns CDATA #FIXED ''>
<!ELEMENT threshold (description,levels)>
<!ATTLIST threshold xmlns CDATA #FIXED '' alias NMTOKEN #IMPLIED
map NMTOKEN #REQUIRED>
<!ELEMENT description (#PCDATA)>
<!ATTLIST description xmlns CDATA #FIXED ''>
<!ELEMENT levels (#PCDATA)>
<!ATTLIST levels xmlns CDATA #FIXED '' divisor CDATA #REQUIRED
height CDATA #REQUIRED width CDATA #REQUIRED>
]>
<thresholds>
<threshold map="hlines2x2" alias="hlines2">
<description>Horizontal lines 2x2</description>
<levels width="2" height="2" divisor="10">
3 3
9 9
</levels>
</threshold>
<threshold map="vlines2x2" alias="vlines2">
<description>Vertical lines 2x2</description>
<levels width="2" height="2" divisor="10">
9 9
3 3
</levels>
</threshold>
<threshold map="diag2x2" alias="diag2">
<description>Diagonal lines 2x2</description>
<levels width="2" height="2" divisor="10">
9 3
3 9
</levels>
</threshold>
<threshold map="7col-1-bool" alias="7c1b">
<description>7-color non-mixing dither, color one boolean</description>
<levels width="8" height="8" divisor="2">
1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-2-bool" alias="7c2b">
<description>7-color non-mixing dither, color two boolean</description>
<levels width="8" height="8" divisor="2">
0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-3-bool" alias="7c3b">
<description>7-color non-mixing dither, color three boolean</description>
<levels width="8" height="8" divisor="2">
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 1 0 1 0 1 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 0 1 0 1 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
</levels>
</threshold>
<threshold map="7col-4-bool" alias="7c4b">
<description>7-color non-mixing dither, color four boolean</description>
<levels width="8" height="8" divisor="2">
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-5-bool" alias="7c5b">
<description>7-color non-mixing dither, color five boolean</description>
<levels width="8" height="8" divisor="2">
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-6-bool" alias="7c6b">
<description>7-color non-mixing dither, color six boolean</description>
<levels width="8" height="8" divisor="2">
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
</levels>
</threshold>
<threshold map="7col-7-bool" alias="7c7b">
<description>7-color non-mixing dither, color seven boolean</description>
<levels width="8" height="8" divisor="2">
0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
</levels>
</threshold>
<threshold map="7col-1" alias="7c1">
<description>7-color non-mixing dither, color one</description>
<levels width="8" height="8" divisor="5">
1 0 2 0 1 0 2 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 3 0 4 0 3 0 4
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
3 0 4 0 0 0 0 0
0 0 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-2" alias="7c2">
<description>7-color non-mixing dither, color two</description>
<levels width="8" height="8" divisor="5">
0 0 0 0 0 0 0 0
0 1 0 2 0 1 0 2
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
3 0 4 0 3 0 4 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 3 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-3" alias="7c3">
<description>7-color non-mixing dither, color three</description>
<levels width="8" height="8" divisor="5">
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 0 2 0 1 0 2 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 3 0 4 0 3 0 4
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 3
</levels>
</threshold>
<threshold map="7col-4" alias="7c4">
<description>7-color non-mixing dither, color four</description>
<levels width="8" height="8" divisor="5">
0 1 0 0 0 0 0 0
0 0 2 0 0 0 0 0
0 0 0 3 0 0 0 0
0 0 0 0 4 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 2 0
0 0 0 0 0 0 0 3
4 0 0 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-5" alias="7c5">
<description>7-color non-mixing dither, color five</description>
<levels width="8" height="8" divisor="5">
0 0 0 1 0 0 0 0
0 0 0 0 2 0 0 0
0 0 0 0 0 3 0 0
0 0 0 0 0 0 4 0
0 0 0 0 0 0 0 1
2 0 0 0 0 0 0 0
0 3 0 0 0 0 0 0
0 0 4 0 0 0 0 0
</levels>
</threshold>
<threshold map="7col-6" alias="7c6">
<description>7-color non-mixing dither, color six</description>
<levels width="8" height="8" divisor="5">
0 0 0 0 0 2 0 0
0 0 0 0 0 0 3 0
0 0 0 0 0 0 0 4
1 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0
0 0 3 0 0 0 0 0
0 0 0 4 0 0 0 0
0 0 0 0 1 0 0 0
</levels>
</threshold>
<threshold map="7col-7" alias="7c7">
<description>7-color non-mixing dither, color seven</description>
<levels width="8" height="8" divisor="5">
0 0 0 0 0 0 0 4
1 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0
0 0 3 0 0 0 0 0
0 0 0 4 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 2 0 0
0 0 0 0 0 0 3 0
</levels>
</threshold>
</thresholds>