Permalink
Browse files

initial thing that passes its training set

  • Loading branch information...
0 parents commit 96141b801a5d79f558f89fcd6cf03e2d078bbcaf @substack committed Oct 5, 2012
@@ -0,0 +1,26 @@
+var fs = require('fs');
+var Canvas = require('canvas');
+var Image = Canvas.Image;
+var rgb2hsl = require('color-convert').rgb2hsl;
+
+var canvas = new Canvas(1280 / 4, 720 / 4);
+var ctx = canvas.getContext('2d');
+
+fs.readFile(process.argv[2], function (err, src) {
+ var img = new Image();
+ img.src = src;
+ ctx.drawImage(img, 0, 0, img.width / 4, img.height / 4);
+
+ var data = ctx.getImageData(0, 0, img.width / 4, img.height / 4).data;
+
+ var matches = 0;
+ for (var i = 0; i < data.length; i += 4 * 8) {
+ var hsl = rgb2hsl(data[i], data[i + 1], data[i + 2]);
+ var h = hsl[0], s = hsl[1], l = hsl[2];
+
+ if ((h < 20 || h > (360 - 20)) && s > 30 && l > 30 && l < 150) {
+ matches ++;
+ }
+ }
+ console.log(matches > 30);
+});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 96141b8

Please sign in to comment.