back to index | | home .

dithering, color depth tests


testing image dithering with imagemagick 6.9.7-4 on debain, syntax is different from windows. not sure about mac with homebrew.
for basic setup,

convert +dither -colors 3 -depth 4 -morphology open octagon:1 input_jpg output_jpg

test images: https://i.imgur.com/Yqf5uHc.png

1   2   3  
4   5   6  
7   8   9  
10  11  12  
13  

Only change parameter for -colors, output filename includes the value used.
1.building

convert +dither -colors 3 .... bld_jpg bld_c3_jpg #2  
convert +dither -colors 2 .... bld_jpg bld_c2_jpg #3  

4.mountain

.. -colors 16 .... mnt_c16_jpg #5  
.. -colors 6 ....  mnt_c6_jpg  #6  

7.mark zb

.... mz_c5_jpg #8  
.... mz_c3_jpg #9  

10.laptop

.... lp_c3_jpg #13  
./watercolor -s 0 -e 5 -m 33 -c 0 laptop_jpg laptop_jpeg #11, fred script  
convert +dither -colors 3 -depth 4 -morphology open octagon:1 \  
-level 25% -contrast laptop_jpeg lp-w-c3-lvl25.jpg #12  

for testing various option:

z=(close dilate erode open) #options for -morphology  
g=1 #octagon value  

#for-loop all jpg in current folder and output to test folder  
for x in *jpg;do  
 for j in ${z[@]};do  ##use z array  
  for i in {2,5,8,16};do  ##-color values  
   convert +dither -colors $i -depth 4 \  
   -morphology "${j}" octagon:$g $x test/${x%.*}-c$i-$j$g.jpg;  
    #example output name: lp-c5-erode1.jpg  
done;done;done  

#in test/, check how many images uses -colors 2 base on filename  
cd test; ls *-c2-*.jpg|wc -l  
$ 36 #example output  

#combine images with same color depth  
for i in {2,5,8,16};do  
 #in my case, theres 36 images per color depth: 2,5,...  
 #for longer or wider stacking images require different sort.  
 ls *-c$i-*.jpg|sort -t- -k3 > testlist;montage @testlist -tile 9x -geometry +2+2 x-c$i.jpeg;  
 #or comment above, and uncomment below for taller stack  
 ##ls *-c$i-*.jpg|sort > testlist;montage @testlist -tile x9 -geometry +2+2 x-c$i.jpeg;  
done  

Aint going in-depth with sort command, it's often trial and error.
another example:

ls *jpg| sort -s -t"-" -k3 -k2.2n > testlist;  
montage @testlist -tile 4x -geometry +0+0 $x$g.jpeg  

with filnames: lp-c5-erode1 bld-c16-open1 lp-c2-erode1 mz-c5-dilate1 etc.
- as delimiter, first alphabetically sort by third column. Then second value after c in second column.
resulting:

mz-c5-dilate1  
lp-c2-erode1  
lp-c5-erode1  
bld-c16-open1  

use sort -r ... to reverse result
text dump: https://hemisc.neocities.org/im/posterize2.txt