Skip to content

Instantly share code, notes, and snippets.

@EmilyAShaw
Forked from dribnet/.block
Last active May 19, 2017 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EmilyAShaw/dcdaef514a3553a0e3676e35206cdf38 to your computer and use it in GitHub Desktop.
Save EmilyAShaw/dcdaef514a3553a0e3676e35206cdf38 to your computer and use it in GitHub Desktop.
17.1.MDDN242 PS3
license: mit
downloads
resized
colorgrid
smartgrid
customgrid
// note: this file is poorly named - it can generally be ignored.
// helper functions below for supporting blocks/purview
function saveBlocksImages(doZoom) {
if(doZoom == null) {
doZoom = false;
}
// generate 960x500 preview.jpg of entire canvas
// TODO: should this be recycled?
var offscreenCanvas = document.createElement('canvas');
offscreenCanvas.width = 960;
offscreenCanvas.height = 500;
var context = offscreenCanvas.getContext('2d');
// background is flat white
context.fillStyle="#FFFFFF";
context.fillRect(0, 0, 960, 500);
context.drawImage(this.canvas, 0, 0, 960, 500);
// save to browser
var downloadMime = 'image/octet-stream';
var imageData = offscreenCanvas.toDataURL('image/jpeg');
imageData = imageData.replace('image/jpeg', downloadMime);
p5.prototype.downloadFile(imageData, 'preview.jpg', 'jpg');
// generate 230x120 thumbnail.png centered on mouse
offscreenCanvas.width = 230;
offscreenCanvas.height = 120;
// background is flat white
context = offscreenCanvas.getContext('2d');
context.fillStyle="#FFFFFF";
context.fillRect(0, 0, 230, 120);
if(doZoom) {
// pixelDensity does the right thing on retina displays
var pd = this._pixelDensity;
var sx = pd * mouseX - pd * 230/2;
var sy = pd * mouseY - pd * 120/2;
var sw = pd * 230;
var sh = pd * 120;
// bounds checking - just displace if necessary
if (sx < 0) {
sx = 0;
}
if (sx > this.canvas.width - sw) {
sx = this.canvas.width - sw;
}
if (sy < 0) {
sy = 0;
}
if (sy > this.canvas.height - sh) {
sy = this.canvas.height - sh;
}
// save to browser
context.drawImage(this.canvas, sx, sy, sw, sh, 0, 0, 230, 120);
}
else {
// now scaledown
var full_width = this.canvas.width;
var full_height = this.canvas.height;
context.drawImage(this.canvas, 0, 0, full_width, full_height, 0, 0, 230, 120);
}
imageData = offscreenCanvas.toDataURL('image/png');
imageData = imageData.replace('image/png', downloadMime);
p5.prototype.downloadFile(imageData, 'thumbnail.png', 'png');
}

PS3 MDDN 242 2017

Final

Bags from the iconic. I decided for my final I would select all bags, male and female from the site theiconic.co.nz. I chose this based on my idea for shoes - I really liked shoes but I did want something a bit more colourful, and shoe was limited to mostly black, grey, brown, nude, and white. Where as bags often come in a huge range of styles and colours. I took the concept of industrial and uniformity from the shoes, as I still wanted to use the iconic website for it’s similar background/angle photography techniques.

images I manually filtered out. I filtered out the images in the downloads folder, that included hands and fingers in them. i did this to encourage the uniformity of the piece, and having skin tones and hands thought this would not have done so efficiently. I also made the decision to filter out a lot of black, as black is a very common colour when it comes to handbags.

I really really like the colour grid - I have chosen this one to focus on, as even though smartgrid did a good job at ordering them by size, colour grid did a more distinct job by ordering by colour. I believe this is because the bags are are distinct in their colour than they are by size and shape. Custom grid did not do as much for me, as it seemed to order it by handle vs no handle.

The zones that were particularly effective were top right and the mid left, the mid left is almost entirely backpacks. I believe this is because most of the images are filled up with backpack, and therefore according to the algorithm appear darker and bigger. The top right is dedicated solely to purses which is cool, I think this has been done for the same yet opposite reason...

#!/bin/bash
# show commands and stop if there is an error
set -ex
# make the directory if it is not there
mkdir -p downloads
# clean the directory if there are old results
rm -f downloads/*
SEARCH_STRING="snow"
# get 5 pages
for PAGE in {1..35}
do
# this is an example with a group
#URL='https://www.flickr.com/groups/awesomesnowflakes/pool/page'$PAGE
#URL='http://www.theiconic.co.nz/womens-shoes/?page='$PAGE
URL='http://www.theiconic.co.nz/womens-accessories-bags/?page='$PAGE
# this is an example with tags
#URL='https://www.flickr.com/photos/tags/'$SEARCH_STRING'/page'$PAGE
#URL='http://designspiration.net/search/saves/page/'$PAGE'/?q=blue'
echo "about to fetch URL: " $URL
sleep 3
# fetch the images
wget --adjust-extension \
--random-wait \
--limit-rate=100k \
--span-hosts \
--convert-links \
--backup-converted \
--no-directories \
--timestamping \
--page-requisites \
--directory-prefix=downloads \
--execute robots=off \
--accept=.jpg \
$URL
# other unused arguments
# --recursive \
# --level 1 \
# --domains en.wikipedia.org \
done
#!/bin/bash
if [ ! -d "/usr/local/anaconda/extras" ]; then
# Control will enter here if DIRECTORY doesn't exist.
echo "smartgrid program not found"
echo "please first install using directions on blackboard"
exit 1
fi
# show commands and stop if there is an error
set -ex
HOME="/usr/local/anaconda/extras/home"
export PATH="/usr/local/anaconda/bin:$PATH"
python /usr/local/anaconda/extras/smartgrid.py \
--tile 25x16 \
--input-glob 'resized/*' \
--left-image 'resized/http%2F%2Fstatic.theiconic.com.au%2Fp%2Fnaked-vice-0231-592394-1.jpg' \
--right-image 'resized/http%2F%2Fstatic.theiconic.com.au%2Fp%2Ftoms-0231-288784-1.jpg' \
--output-path customgrid
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"></script>
<style>
body {padding: 0; margin: 0;}
#image-map {
width: 960;
height: 500;
border: 1px solid #ccc;
margin-bottom: 10px;
}
</style>
</head>
<body style="background-color:white">
<div id="image-map"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script language="javascript" type="text/javascript" src="zoom_image.js"></script>
<br>
<a href="montage.jpg">full size montage</a><br>
<a href="left_right.jpg">left right images</a><br>
<a href="tsne.png">tsne</a><br>
<a href="tsne_spun.png">tsne spun</a><br>
<a href="movement.png">movement</a><br>
</body>
#!/bin/bash
if [ -d "/usr/local/anaconda/extras" ]; then
# Control will enter here if DIRECTORY doesn't exist.
echo "smartgrid program already installed"
exit 1
fi
# show commands and stop if there is an error
set -ex
# make the directory if it is not there
mkdir -p /tmp/smartgrid
# clean the directory if there are old results
rm -f /tmp/smartgrid/*
cd /tmp/smartgrid
wget http://deeptom.staff.vuw.ac.nz:9000/smartgrid.tgz
cd /usr/local
tar xvfz /tmp/smartgrid/smartgrid.tgz
echo "DONE: smartgrid program installed"
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment