John Smith commited on 2022-295 17:09:45
Showing 1 changed files, with 23 additions and 0 deletions.
occlude.sh, given an image, generates a set of images with rectangular regions occluded, which assists the user to create image-memorisation cards.
| ... | ... |
@@ -0,0 +1,23 @@ |
| 1 |
+#!/bin/sh |
|
| 2 |
+# occlude - generate a set of images with rectangular sections occluded |
|
| 3 |
+# usage: occlude img |
|
| 4 |
+# Displays img in iv and generates a numbered occluded image |
|
| 5 |
+# for every two middle-clicks (which select a position in the image). |
|
| 6 |
+ |
|
| 7 |
+IFS=', ' |
|
| 8 |
+BFN="${1%.*}"
|
|
| 9 |
+FE="${1##*.}"
|
|
| 10 |
+CTR=1 |
|
| 11 |
+'/usr/local/bin/iv' "$1" | while read X Y |
|
| 12 |
+do |
|
| 13 |
+ if [ -n "$SX" ] |
|
| 14 |
+ then |
|
| 15 |
+ magick "$1" -fill black -draw "rectangle ${SX},${SY} ${X},${Y}" "${BFN}_${CTR}.${FE}"
|
|
| 16 |
+ SX='' |
|
| 17 |
+ SY='' |
|
| 18 |
+ CTR="$((CTR+1))" |
|
| 19 |
+ else |
|
| 20 |
+ SX="$X" |
|
| 21 |
+ SY="$Y" |
|
| 22 |
+ fi |
|
| 23 |
+done |
|
| 0 | 24 |