Thursday, 30 December 2010

Postprocessing scanned crayon images

Postprocessing crayon drawings

I have some scans of crayon drawings, but the colours are washed out (well, the colours are pretty light on paper too):


First, some due dilligence. Google for solutions. (Actually, first fire up GIMP and try a few ideas. But let's pretend I hit the books before hitting the lab).

Lit review:

  1. google'd: post processing scanned crayon drawings - no help, but kids drawing reenacted was entertaining.

  2. google'd: scanning crayon drawings - better, results in a yahoo answers entry... which suggests GIMP. Also a couple of references warning about crayon wax sticking to scanners (I didn't have this problem).

  3. searched flickr for examples in the hope of finding a discussion in comments. Photos tagged with crayon art was the best of the flickr searches. Several people, including Steve brandon, used a camera, rather than a scanner.


Ok, that's enough searching. Let's play with some balances. Here's screenshots of the settings (from GIMP's colour menu) and the changed versions of the image.

original


take 1






take 2





I bumped up blue similarly.


take 3





Applied these settings after inverting the image.


take 4






take 5





I expanded this settings box out to make fine control easier.



In the end I went with the first take, as the least abstract of the bunch.


Tuesday, 28 December 2010

Wednesday, 1 December 2010

The Hive Brisbane, 2010-11-30 - interesting people with exciting projects

I went to a The Hive event today yesterday, featuring Richard Slatter from We Are Hunted.

I enjoyed the event. They talk was good but the best bit of the evening was talking to some interesting people about their exciting projects:

  • The speaker, Richard Slatter, about We Are Hunted (music charts based on online chatter) and the advantages of RERO.

  • Alice and Leo from Davinway Marketing, who are applying agile methodologies to marketing (which is an idea that appeals to me).

  • Mike Boyd, part of The Hive's Brisbane team, who's working on Cupstart, a project that will let you "Order your coffee online using Cupstart and collect it as you arrive". Oh, he also has a survey.

Tuesday, 23 November 2010

WP7 developer signup ToS wordcount

Registering as a developer in order to publish Windows Phone 7 apps involves the following Terms of Use.
(the numbers are approximate word counts).



36752 words total. Word counts are approximate.

From https://users.create.msdn.com/Register/
10935 - App Hub Terms of Use ( http://go.microsoft.com/?linkid=9740471 )
1308 - Xbox LIVE Code of Conduct ( http://www.xbox.com/en-US/legal/codeofconduct )
4751 - Microsoft Online Privacy Notice ( http://go.microsoft.com/?linkid=9740471 )
505 - Microsoft Anti-Spam Policy ( http://privacy.microsoft.com/en-us/anti-spam.mspx )
6316 - Windows Phone Marketplace Application Provider Agreement ( http://go.microsoft.com/?linkid=9739544 )
?? - Refund Policy ( http://create.msdn.com/resources/en-ww/MarketplaceRefundPolicies.pdf - dead link)
3230 - GeoTrust Code Signing Certificate Subscriber Terms
1931 - Xbox LIVE Indie Games game submission agreement
?? - Terms of Use ( http://create.msdn.com/termsofuse - dead link - redirects to register page)
?? - Code of Conduct ( http://create.msdn.com/conduct - dead link)

And then to pay them money:
7776 - Xbox LIVE and Games for Windows LIVE Terms of Use


I didn't count the ToSs for Windows 7, Visual studio, Windows Live etc. I also didn't count every document referenced by another document, just some of them.


Edit: the http://create.msdn.com/termsofuse link is only dead until after you have an account. I still don't count it, because it wasn't something I could read before signing up.

Tuesday, 14 September 2010

Quad Negative

This didn't fail to amused me. From http://210.8.42.125/other/accagr1.shtml :

The User will not use, nor will it sell or make available to any person,
the Information for the purpose of issuing Independent Forecasts or
Warnings unless:
...
(ii) the additional forecasting elements are not inconsistent with the
Bureau's Forecast;


TLDR: Will not ... unless ... not inconsistent

Saturday, 11 September 2010

Starcraft 2 Automated Unit Tests

No, not that sort of unit test.

As an exercise, I made a Starcraft 2 map that pits various sizes of starting-unit squads against each other. This post covers the initial results of my test.



This graph shows how many units Player 1 (P1) had left after attack moving through Player 2's (P2) squad (while P2's squad was likewise attack moving through P1's squad). All the fights resulted in victory for one side, so if P1 had any units left, P2 had none. Only fights that P1 won are displayed. It says "no micro" because there was no micromangement, only the default AI was used. A good human player can improve a unit's performance by issuing more specific orders (focusing fire, pulling back damaged units etc).

How to read the graph


The first column of subgraphs shows the fights where P1 used Marines. Likewise the first row of subgraphs shows the fights were P2 used Marines. Within each subgraph, the number of units that each player starts with is varied from 1 to 8. The leftmost column of each subgraph shows the results of fights where P1 started with only 1 unit. The topmost row of each subgraph shows the fights where P2 started with 8 units. Diagonal lines have been drawn through the numerically even fights (based on count of units, not cost).

Data



The CSV file I used to generate the above chart can be found at http://abznak.com/pub/20100911.unittests.csv. You can ignore the columns with names beginning with "x". The other columns are, I hope, self explanatory.

Method



I created a SC2 map that, every 30s, tested the next combination from:
type_1:[marine, zealot, zergling] x count_1:[1..8] x type_2:[marine, zealot, zergling] x count_2:[1..8]

The test consisted of:

  1. Spawn count_1 units of type type_1 at point_1

  2. tell them to attack point_2

  3. Spawn count_2 units of type type_2 at point_2

  4. tell them to attack point_1



I think all 4 of the actions happen at the same game time. Point 1 and point 2 were on an empty flat surface, on a horizontal line, 15m apart. (I'm going to call whatever distance unit the map editor uses "m", as saying "15 units apart" is confusing).

None of the units had any upgrades.

Discussion


marines splitting fire between 2 zealots

In this situation, 2 zealots will beat 7 'lings and 3 zealots will beat 7 marines. But the there was no micromanagement, so, for example, in the 8 marines vs 8 zealots case the marines split their fire between the two lead zealots. Also, each test was only done once. Subsequent experiments have show that the outcomes are not always the same (sometimes one zealot will die in 8xZealot vs 8xMarines, sometimes all zealots survive).

Those of you that don't know SC2 should also note that for 100 Minerals you can by 1 zealot, 2 marines or 4 zerglings.

Software


I used the SC2 map editor, some commandline tools, R and ggplot2. Do email me if you'd like a copy of the map (maps at abznak.com). It's currently just a bit rough to publish.

Future Work



  • Try different units

  • Try repeating tests

  • Try fractions of units (i.e. damaged units)

  • Clean up the map

  • Write up the map

  • Write up the R code




But that's going to have to wait, because I feel like actually playing some SC2 now. I'm thinking 3 zealot rush.

Monday, 30 August 2010

iPad post

First time I have used an I pad, someone had left safari running. First thing I did, google "iPad alt tab".
http://noscope.com/journal/2010/01/why-the-ipad-doesnt-have-multi-tasking suggests the home button which seems to be the hw button with the square on it.

Touch typing:
Quality of a netuoy us bot sttauobed.

Hmm, no.

PS: In case it wasn't obvious, I did all that on an iPad. The post is a little unclear because typing was so much work.

Edit: Added PS using a real keyboard, so much nicer.

Tuesday, 24 August 2010

So, I make websites

Hello to everyone visiting because I gave them them this link at OPD today.

So, I make websites as my day job. If you're a celebrant (or any small business) and would like me to give you a quote to build, host and/or maintain your website please don't hesitate email me at work@leetmotif.net.


For the record, "leetmotif" is a play on Leitmotif and Leet.



Celebrant OPD

I just returned from a course of Ongoing Professional Development for Celebrants from Australian Celebrations Training.

Amusingly, during the Social Media part of the presentation the presenter kindly asked if I made websites and let me plug this site. Thanks Beth.

So, I've hurried back to update the site.

Saturday, 24 July 2010

Building VLC on Ubuntu

Exciting apt command:
apt-get build-dep vlc
downloads vlc's dependencies for me. From VLC's UnixComplie page.

Still doesn't compile. OK, new plan:
update-manager -d
alpha FTW.

Wednesday, 9 June 2010

RMySQL and mysql connector odbc 5.1.6

I think installing mysql-connector-odbc-5.1.6-win32.msi upset RMySQL.

In R, running
library("RMySQL")
gave me
... Error in if (utils::file_test("-d", MySQLhome)) break : ...

Setting MYSQL_HOME to C:\PROGRA~1\MySQL\MYSQLS~1.0
fixed the problem (using XP's System, Advanced, Environment Variables, System Variables).

References:
https://stat.ethz.ch/pipermail/r-sig-db/2009q2/000648.html
http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL

Edit:
Except that only lets me load the library, connecting doesn't work now. Gave it the mysqllib.dll that comes with HeidiSQL, that'll work until mysql-5.1.47-win32.msi finishes downloading (copied the dll into a dir called "bin", set MYSQL_HOME to dir that bin dir was in).

Thursday, 20 May 2010

Fixing annoying Australia-centric google results: &gl=

Google seems to prefer giving me Australian results to some of my searches. This is often useful, but sometimes it's annoying.

It looks like adding "&gl=" to the request disables this feature.

Judging by my quick experiments (see below) it's using gl=au by default.













http://www.google.com.au/search?q=university australian results
http://www.google.com.au/search?q=university&gl= world results
http://www.google.com.au/search?q=university&gl=au australian results (same as australian results above)
http://www.google.com.au/search?q=university&gl=uk uk results


The following searches, however, seemed to have only minor variations, with no obvious country biases:

http://www.google.com.au/search?q=smtp+server+component
http://www.google.com.au/search?q=smtp+server+component&gl=
http://www.google.com.au/search?q=smtp+server+component&gl=au
http://www.google.com.au/search?q=smtp+server+component&gl=uk


The effects of the GL parameter seem to be different from using the

* The web
* Pages from Australia

options sometimes available on the left of a google search.

Also note, something I've done (I suspect clicking on the "The web" link) has changed the results I'm now getting for the GL-less seaches.

Oh, I found out about the parameter from http://www.searchmasters.co.nz/articles/204/country-bias-in-google-search-results/

Thursday, 6 May 2010

finding <? that aren't <?php

I'm using this pattern (in vim) to find "<?" that aren't "<?php":

\(<?\)\@<=\(php\)\@!

it uses zero-width look behind for the "<?" and zero width negative look ahead for the "php".

And using grep (in perl mode):

grep -P "\<\?(?!php)" -r .


Test cases:

YES <?
NO <?php
YES <?=
YES <? asdf
YES <?adsf
NO asdg



And a quick shell script for fixing a file (I say "quick" because it doesn't always work - e.g. if you have "<?/* comment */?>" it doesn't put in the extra whitespace you need after the "<?php"):

sed 's/<?=/MAGICaaxo3ohW/' | sed 's/<?php/<?/g' | sed 's/<?/<?php/g' | sed 's/MAGICaaxo3ohW/<?php echo/'

Thursday, 29 April 2010

ggplot2 background colour

changing the background colour of a ggplot - run this, then rerun plot

> th = theme_bw()
> th$panel.background
theme_rect(fill = "white", colour = NA)
> th$panel.background = theme_rect(fill = "black", colour = NA)
> theme_set(th)

Thursday, 15 April 2010

Zend Soap Client exception

If Zend_Soap_Client is giving you an "Invalid SOAP request" and you don't know why, try adding "$client->setSoapVersion(SOAP_1_1);".

The error I was getting:

[SoapFault]
Invalid SOAP request
stack trace

* at ()
in C:\xampplite\php\PEAR\Zend\Soap\Client.php line 1113 ...
1110. $this->_preProcessArguments($arguments),
1111. null, /* Options are already set to the SOAP client object */
1112. (count($soapHeaders) > 0)? $soapHeaders : null,
1113. $this->_soapOutputHeaders);
1114.
1115. // Reset non-permanent input headers
1116. $this->_soapInputHeaders = array();


Thanks to Mark Steudel's comment at the zend soap client page

Friday, 19 March 2010

Drupal and php snippets

useful link: http://drupal.org/handbook/customization/php-snippets

to get php in blocks, enable the Php Filter in the modules section.

I've managed to break a site (so that nothing renders because of a php error in a block) and fix it by posting a page that I already had open with that block being edited.

I haven't had to work out how to perform such a fix without that lucky open page (yet).

Monday, 8 February 2010

Drupal, Zen, Nice Menus

If you're using trying to use Nice Menus to make a Zen subtheme for Drupal, you might need to remove the "overflow: hidden" from the navbar block in layout.css if you're having trouble with your menus not working or only partly showing up.

Here's a quote from layout.css (the comment is not mine):

#navbar
{
overflow: hidden;
/* May need to be removed if using
a dynamic drop-down menu */
}


Monday, 1 February 2010

Fragments of CSS


a:hover {color: green; text-shadow: #FF0000 1px 1px 3px}


Sunday, 17 January 2010

Adding navigation links to drupal

The menu item I was looking for is Home � Administer � Site building � Menus >Primary links

Friday, 8 January 2010

Opera Mobile 9.5 Tab Limit

Opera on my mobile limits me to two tabs.

The trick to fix this is go to opera:config and search for 'tab'. Then change the value, save and restart.