Skip to content
Snippets Groups Projects
Commit 7bba978f authored by Toke Eskildsen's avatar Toke Eskildsen
Browse files

Added scripts and support files from internal project

parent 76f70f76
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quack - ${SRC_FOLDER}</title>
<link rel="stylesheet" type="text/css" href="${UP}quack.css" />
</head>
<body class="folder">
<h1>Quack <span style="color: #999">${SRC_FOLDER}</span></h1>
<!-- TODO: Create decent bread crumbs -->
<p>Parent folder: <a href="../index.html">${PARENT}</a></p>
<div class="images">
<h2>Pages</h2>
<div class="thumbs">${THUMBS_HTML}</div>
<div class="imagelinks">
${IMAGES_HTML}
</div>
</div>
<div class="subfolders">
<h2>Subfolders</h2>
${SUBFOLDERS_HTML}
</div>
<div class="edition">
<h2>Edition XML</h2>
${EDITION_HTML}
</div>
</body>
</html>
#!/bin/bash
TOPX=20
WEBROOT="http://pc254.sb.statsbiblioteket.dk/quack/tilbud2/"
LOG=$1
if [ "." == ".$LOG" ]; then
echo "Usage: ./greyscale_report.sh logfile [html]"
exit -1
fi
TYPE=$2
if [ "." != ".$TYPE" ]; then
if [ "html" != "$TYPE" ]; then
echo "The only valid type is html. $TYPE was specified"
exit -1
fi
fi
if [ "html" == "$TYPE" ]; then
echo "<html>"
echo "<head><title>Report for $LOG</title></head>"
echo "<body>"
echo "<h1>Report for $LOG with `cat $LOG | wc -l` analyzed images</h1>"
else
echo "Report for $LOG with `cat $LOG | wc -l` analyzed images"
fi
echo ""
# Stats for unique greyscales as well as brightest greyscale
if [ "html" == "$TYPE" ]; then
echo "<h2>Distribution by number of unique greyscales</h2>"
echo "<table>"
echo "<tr><th>#occurrences</th> <th>#uniques</th> <th>brightest greyscale</th></tr>"
else
echo "Distribution by number of unique greyscales"
echo "#occurrences #uniques brightest_greyscale"
fi
# 1. Bucket #unique
UNIQUES=`cat "$LOG" | cut -d " " -f 3 | sort | uniq`
# 2. Extract brightest as well as count for each #unique
for U in $UNIQUES; do
COUNT=`cat "$LOG" | cut -d " " -f 3,9 | grep "$U (" | wc -l`
if [ "html" == "$TYPE" ]; then
echo -n "<tr><td>$COUNT</td> <td>$U</td> <td>"
echo -n `cat "$LOG" | cut -d " " -f 3,9 | grep "$U (" | cut -d " " -f 2 | sort -u`
echo "</td></tr>"
else
echo -n "$COUNT $U "
echo `cat "$LOG" | cut -d " " -f 3,9 | grep "$U (" | cut -d " " -f 2 | sort -u`
fi
done
if [ "html" == "$TYPE" ]; then
echo "</table>"
fi
echo ""
if [ "html" == "$TYPE" ]; then
echo "<h2>Percent of image with darkest greyscale, top $TOPX</h2>"
echo "<table>"
echo "<tr><th>percent</th> <th>darkest greyscale</th> <th>link</th></tr>"
else
echo "Percent of image with darkest greyscale, top $TOPX"
fi
for P in `cat "$LOG" | cut -d " " -f 5 | sort -n -r | head -n $TOPX`; do
LINE=`cat "$LOG" | cut -d " " -f 1,5,6 | grep " $P (" | cut -d " " -f 1,3 | head -n 1`
if [ "html" == "$TYPE" ]; then
C=`echo "$LINE" | cut -d " " -f 2`
I=`echo "$LINE" | cut -d " " -f 1`
REF=${I##*/}
REF="${REF%.*}"
LINK="$WEBROOT${I%.*}.html"
echo "<tr><td>${P}%</td> <td>$C</td> <td><a href=\"$LINK\">$REF</a></td></td></tr>"
else
echo "${P}% `echo "$LINE" | cut -d " " -f 2` `echo "$LINE" | cut -d " " -f 1`"
fi
done
if [ "html" == "$TYPE" ]; then
echo "</table>"
fi
echo ""
if [ "html" == "$TYPE" ]; then
echo "<h2>Percent of image with brightest greyscale, top $TOPX</h2>"
echo "<table>"
echo "<tr><th>percent</th> <th>brightest greyscale</th> <th>link</th></tr>"
else
echo "Percent of image with brightest greyscale, top $TOPX"
fi
for P in `cat "$LOG" | cut -d " " -f 8 | sort -n -r | head -n $TOPX`; do
LINE=`cat "$LOG" | cut -d " " -f 1,8,9 | grep " $P (" | cut -d " " -f 1,3 | head -n 1`
if [ "html" == "$TYPE" ]; then
C=`echo "$LINE" | cut -d " " -f 2`
I=`echo "$LINE" | cut -d " " -f 1`
REF=${I##*/}
REF="${REF%.*}"
LINK="$WEBROOT${I%.*}.html"
echo "<tr><td>${P}%</td> <td>$C</td> <td><a href=\"$LINK\">$REF</a></td></td></tr>"
else
echo "${P}% `echo "$LINE" | cut -d " " -f 2` `echo "$LINE" | cut -d " " -f 1`"
fi
done
if [ "html" == "$TYPE" ]; then
echo "</table>"
fi
if [ "html" == "$TYPE" ]; then
echo "</body>"
echo "</html>"
fi
#!/bin/bash
# Input: A greyscale image
# Output: Name pixel_count unique_greyscales #darkest_pixels darkest_pixels_percent darkest_greyscale #brightest_pixels brightest_pixels_percent lightest_greyscale
TMP="/tmp/tmp_crop.bmp"
if [ "." == ".$1" ]; then
echo "Usage: filename [croppercent]"
exit 2
fi
if [ "." != ".$2" ]; then
CROP=$2
convert "$1" -gravity Center -crop $CROP%x+0+0 "$TMP" 2> /dev/null
INFO=`identify -verbose "$TMP" 2> /dev/null`
rm "$TMP"
else
INFO=`identify -verbose $1 2> /dev/null`
fi
#INFO=`cat t`
SAVEIFS=$IFS
IFS=$(echo -en "\n")
UNIQUE=`echo $INFO | grep "[0-9]\\+: (" | wc -l`
FIRST_COUNT=`echo $INFO | grep "[0-9]\\+: (" | head -n 1 | grep -o " [0-9]\\+:" | grep -o "[0-9]\\+"`
FIRST_GREY=`echo $INFO | grep "[0-9]\\+: (" | head -n 1 | grep -o " ([0-9 ,]*)" | sed 's/ //g'`
LAST_COUNT=`echo $INFO | grep "[0-9]\\+: (" | tail -n 1 | grep -o " [0-9]\\+:" | grep -o "[0-9]\\+"`
LAST_GREY=`echo $INFO | grep "[0-9]\\+: (" | tail -n 1 | grep -o " ([0-9 ,]*)" | sed 's/ //g'`
GEOMETRY=`echo $INFO | grep "Geometry: [0-9]\\+x[0-9]\\+" | grep -o "[0-9]\\+x[0-9]\\+"`
X=`echo $GEOMETRY | grep -o "[0-9]\\+x" | grep -o "[0-9]\\+"`
Y=`echo $GEOMETRY | grep -o "x[0-9]\\+" | grep -o "[0-9]\\+"`
PIXELS=`echo "$X*$Y" | bc`
PERCENT_FIRST=`echo "scale=2;$FIRST_COUNT*100/$PIXELS" | bc`
PERCENT_LAST=`echo "scale=2;$LAST_COUNT*100/$PIXELS" | bc`
echo "$1 $PIXELS $UNIQUE $FIRST_COUNT $PERCENT_FIRST $FIRST_GREY $LAST_COUNT $PERCENT_LAST $LAST_GREY"
#echo "$1 $UNIQUE $LAST"
IFS=$SAVEIFS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Quack - ${IMAGE}</title>
<link rel="stylesheet" type="text/css" href="${UP}quack.css" />
<script src="${UP}openseadragon.min.js"></script>
<script src="${UP}quack.js"></script>
<script>
${OCR_CONTENT}
${IDNEXTS}
${IDPREVS}
</script>
<style>
.whiteoverlay {
background: url(${WHITE});
background-size: 100% auto;
}
.blackoverlay {
background: url(${BLACK});
background-size: 100% auto;
}
</style>
</head>
<body class="previewpage">
<h1>Quack <span style="color: #999">${IMAGE}</span></h1>
<div id="controlpanel" class="control">
<p class="navigation">${NAVIGATION}</p>
${ALTERNATIVES}
<p class="histogram"><img src= "${HISTOGRAM}" width="256" height="200" alt="histogram"/></p>
<p><input type="checkbox" id="toggle_grid" onClick="toggleGrid();">Grid</input></p>
<p><input type="checkbox" id="toggle_textblock" checked="checked" onClick="toggleTextBlock();">TextBlocks</input></p>
<p><input type="checkbox" id="toggle_blown" onClick="toggleBlown();">Black/white</input></p>
<div id="idbox">ID: </div>
<div id="idnextbox">IDNEXT: </div>
<div id="ocrbox"> </div>
</div>
<div id="zoom-display" class="openseadragon">
<div id="gridbox">
<div class="gridline gridlinex" style="top: 100px"></div>
<div class="gridline gridlinex" style="top: 200px"></div>
<div class="gridline gridlinex" style="top: 300px"></div>
<div class="gridline gridlinex" style="top: 400px"></div>
<div class="gridline gridlinex" style="top: 500px"></div>
<div class="gridline gridlinex" style="top: 600px"></div>
<div class="gridline gridlinex" style="top: 700px"></div>
<div class="gridline gridlinex" style="top: 800px"></div>
<div class="gridline gridlinex" style="top: 900px"></div>
<div class="gridline gridlinex" style="top: 1000px"></div>
<div class="gridline gridlinex" style="top: 1100px"></div>
<div class="gridline gridlinex" style="top: 1200px"></div>
<div class="gridline gridlinex" style="top: 1300px"></div>
<div class="gridline gridlinex" style="top: 1400px"></div>
<div class="gridline gridlinex" style="top: 1500px"></div>
<div class="gridline gridlinex" style="top: 1600px"></div>
<div class="gridline gridlinex" style="top: 1700px"></div>
<div class="gridline gridlinex" style="top: 1800px"></div>
<div class="gridline gridlinex" style="top: 1900px"></div>
<div class="gridline gridlinex" style="top: 2000px"></div>
<div class="gridline gridliney" style="left: 100px"></div>
<div class="gridline gridliney" style="left: 200px"></div>
<div class="gridline gridliney" style="left: 300px"></div>
<div class="gridline gridliney" style="left: 400px"></div>
<div class="gridline gridliney" style="left: 500px"></div>
<div class="gridline gridliney" style="left: 600px"></div>
<div class="gridline gridliney" style="left: 700px"></div>
<div class="gridline gridliney" style="left: 800px"></div>
<div class="gridline gridliney" style="left: 900px"></div>
<div class="gridline gridliney" style="left: 1000px"></div>
<div class="gridline gridliney" style="left: 1100px"></div>
<div class="gridline gridliney" style="left: 1200px"></div>
<div class="gridline gridliney" style="left: 1300px"></div>
<div class="gridline gridliney" style="left: 1400px"></div>
<div class="gridline gridliney" style="left: 1500px"></div>
<div class="gridline gridliney" style="left: 1600px"></div>
<div class="gridline gridliney" style="left: 1700px"></div>
<div class="gridline gridliney" style="left: 1800px"></div>
<div class="gridline gridliney" style="left: 1900px"></div>
<div class="gridline gridliney" style="left: 2000px"></div>
</div>
</div>
<script type="text/javascript">
myDragon = OpenSeadragon({
id: "zoom-display",
maxZoomLevel: 16,
showNavigator: false,
wrapHorizontal: false,
tileSources: {
type: 'legacy-image-pyramid',
levels:[
{
url: '${IMAGE}',
width: ${IMAGE_WIDTH},
height: ${IMAGE_HEIGHT}
},
]
},
${OVERLAYS}
});
</script>
<!-- TODO: Create decent bread crumbs -->
<p>Parent folder: <a href="index.html">${PARENT}</a></p>
<p>Source: ${SOURCE}</p>
<p>Direct: <a href="${IMAGE}">${IMAGE}</a></p>
<p>Generated: ${DATE}</p>
<div class="alto">
<h2>ALTO XML</h2>
<p>Source: <a href="${ALTO}">${ALTO}</a></p>
${ALTO_ELEMENTS_HTML}
</div>
</body>
</html>
quack.sh 0 → 100755
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment