Commit 5d1364ec by murtaugh

updated

parent 33eab3a6
orig=$(shell ls sample/*.orig.jpg)
trim=$(orig:%.orig.jpg=%.trim.jpg)
contourssvg=$(trim:%.trim.jpg=%.contours.svg)
contourspng=$(trim:%.trim.jpg=%.contours.png)
contoursjson=$(trim:%.trim.jpg=%.contours.json)
gradientsvg=$(trim:%.trim.jpg=%.gradient.svg)
gradientpng=$(trim:%.trim.jpg=%.gradient.png)
gradientjson=$(trim:%.trim.jpg=%.gradient.json)
red=$(trim:%.trim.jpg=%.red.png)
redjson=$(trim:%.trim.jpg=%.red.json)
green=$(trim:%.trim.jpg=%.green.png)
greenjson=$(trim:%.trim.jpg=%.green.json)
blue=$(trim:%.trim.jpg=%.blue.png)
bluejson=$(trim:%.trim.jpg=%.blue.json)
zapzeros:
find sample -size 0 -exec rm {} \;
trim: $(trim)
contours: $(contourspng) $(contourssvg) $(contoursjson)
gradients: $(gradientsvg) $(gradientpng) $(gradientjson)
channels: $(red) $(green) $(blue) $(redjson) $(greenjson) $(bluejson)
sample_with_data.json: sample.json $(contoursjson) $(gradientjson) $(redjson) $(greenjson) $(bluejson)
scripts/joindata.py $^ > $@
cleandata:
rm $(redjson) $(greenjson) $(bluejson) $(gradientjson) $(contoursjson)
# sample.csv: csv/export_mim.csv
sample.csv: csv/mim.normalized.csv
# head -n 101 $< > $@
......@@ -14,11 +41,43 @@ sampleimages: sample.csv
%.trim.jpg: %.orig.jpg
convert $< -gravity South -crop 0x0+0+25 $@
sample.json: sample.csv scripts/csv2sortable.py
scripts/csv2sortable.py $< > $@
sample.json: sample.csv scripts/csv2json.py
scripts/csv2json.py $< > $@
poster.pdf: sample.json scripts/orderings.poster.py
scripts/orderings.poster.py $< --output $@
sample/exif.json:
exiftool -FileModifyDate --json
# Contours
%.contours.png %.contours.svg: %.trim.jpg
contours $< $*.contours.png > $*.contours.svg
%.contours.json: %.contours.svg
scripts/svgcountpaths.py $< --polyline --json --id $*.jpg --key contours --img $*.contours.png > $@
# Gradient
%.gradient.svg: %.trim.jpg
imagegradient.py $< --svg $*.gradient.svg
%.gradient.png: %.gradient.svg
inkscape --export-png=$*.gradient.png --export-background="#FF00FF" $<
%.gradient.json: %.gradient.svg
scripts/svgpathlength.py $< --json --id $*.jpg --key gradient --img $*.gradient.png > $@
# channels
%.red.png %.green.png %.blue.png: %.trim.jpg
channel $< $*.red.png $*.green.png $*.blue.png
%.red.json: %.red.png
convert $< -format %c histogram:info:- | scripts/histcount.py --json --id $*.jpg --key red --img $*.red.png > $@
%.green.json: %.green.png
convert $< -format %c histogram:info:- | scripts/histcount.py --json --id $*.jpg --key green --img $*.green.png > $@
%.blue.json: %.blue.png
convert $< -format %c histogram:info:- | scripts/histcount.py --json --id $*.jpg --key blue --img $*.blue.png > $@
#!/usr/bin/env python3
import argparse, json
ap = argparse.ArgumentParser("gather data sources and join on id")
ap.add_argument("input", nargs="+")
args = ap.parse_args()
byid = {}
for n in args.input:
with open(n) as f:
data = json.load(f)
did = data['id']
del data['id']
if did not in byid:
byid[did] = [data]
else:
byid[did].append(data)
# output = list(byid.values())
# output.sort(key=lambda x: x['id'])
# print (json.dumps(output, indent=2))
output = []
for did in sorted(byid):
output.append({'id': did, 'data': byid[did]})
print (json.dumps(output, indent=2))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment