<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Greger&#039;s blog</title>
	<atom:link href="http://blog.gregerstoltnilsen.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gregerstoltnilsen.net</link>
	<description>Inside info on my art and photography practice.</description>
	<lastBuildDate>Sat, 21 Jan 2012 19:41:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Processing.js plugin for WordPress</title>
		<link>http://blog.gregerstoltnilsen.net/2011/08/processing-js-plugin-for-wordpress/</link>
		<comments>http://blog.gregerstoltnilsen.net/2011/08/processing-js-plugin-for-wordpress/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 14:26:18 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=108</guid>
		<description><![CDATA[I just installed the Processing JS WordPress plugin, and this is just a quick test to see if, and how, it works.]]></description>
			<content:encoded><![CDATA[<p>I just installed the <a href="http://www.keyvan.net/code/processing-js/">Processing JS WordPress plugin</a>, and this is just a quick test to see if, and how, it works.</p>
<p><script type="application/processing">
//Info: http://processingjs.org/reference
class Blob
{
	Blob next;
	int drops;
	int max;
	
	Blob(Blob nextBlob)
	{
		this.next = nextBlob;
		this.drops = 1;
		this.max = 10;
	}
	
	void add(int addDrops)
	{
		this.drops += addDrops;
	}
	
	void update()
	{
		if(this.drops > this.max)
		{
			int push = 0;
			
			push = (this.drops-this.max) + (int)random(this.max);
			
			this.drops -= push;

			if(this.drops < 0) this.drops = 0;

			if(this.next != null)
			{
				this.next.add(push);
			}

		}
		
	}
}

Blob[] strip;
void setup()
{
	size(256, 512);
	strip = new Blob[10];
	strip[9] = new Blob(null);
	for(int i = 8; i >= 0; i--)
	{
		strip[i] = new Blob(strip[i+1]);
	}
	
	frameRate(25);
	smooth();
	noStroke();
}


void draw()
{
	background(192);
	for(int i = 0; i < strip.length; i++)
	{
		ellipse(width/2.0, i*50 + 25, strip[i].drops*4, strip[i].drops*4);
	}
	
	if(frameCount%10 == 0)
	{
		int i = (int)random(strip.length);
		strip[i].add((int)random(4));
	
	}
	if(frameCount%4 == 0)
	{
		strip[(frameCount/4)%strip.length].update();
	}
}
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2011/08/processing-js-plugin-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keeping track of battery status</title>
		<link>http://blog.gregerstoltnilsen.net/2011/06/keeping-track-of-battery-status/</link>
		<comments>http://blog.gregerstoltnilsen.net/2011/06/keeping-track-of-battery-status/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 21:06:00 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[batteries]]></category>
		<category><![CDATA[photography]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/2011/06/keeping-track-of-battery-status/</guid>
		<description><![CDATA[I constantly come up with new ways I think I will use to keep track of the charge status of my camera batteries, but I tend to forget between each time I am on a shoot, so it is kinda silly.   The other day I came up with this: I used a marker, and added <a href='http://blog.gregerstoltnilsen.net/2011/06/keeping-track-of-battery-status/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><img style="display:block;margin-right:auto;margin-left:auto;" alt="image" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/06/wpid-IMAG0209.jpg" /></p>
<p>I constantly come up with new ways I think I will use to keep track of the charge status of my camera batteries, but I tend to forget between each time I am on a shoot, so it is kinda silly.   The other day I came up with this:</p>
<p>I used a marker, and added a plus sign to the battery covers, on one side. When the battery is fresh, the cover is put on so that the plus faces the contacts. When it is flat, the other way around. Now it is easy to see of I have just charged, or used up whatever battery I fish out of my bag. <br />
I also added a piece of gaffers tape on the &#8220;negative&#8221; side, in case the plus gets rubbed off.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2011/06/keeping-track-of-battery-status/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bass synth, work in progress</title>
		<link>http://blog.gregerstoltnilsen.net/2011/04/bass-synth-work-in-progress/</link>
		<comments>http://blog.gregerstoltnilsen.net/2011/04/bass-synth-work-in-progress/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 11:51:24 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Sound]]></category>
		<category><![CDATA[synth]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=91</guid>
		<description><![CDATA[I am working on making a bass synth. It will be controlled by some old organ pedals, but currently it just works by adjusting pots. In the schematics you can see the voltage regulator in the top left. I use 12volt DC in, from an old PC power supply. Which I regulate to 9 volts. <a href='http://blog.gregerstoltnilsen.net/2011/04/bass-synth-work-in-progress/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I am working on making a bass synth. It will be controlled by some old  organ pedals, but currently it just works by adjusting pots.</p>
<p><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/04/bass-synth.png"><img class="size-large wp-image-94 alignnone" title="bass-synth schematics" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/04/bass-synth-1024x701.png" alt="" width="695" height="475" /></a></p>
<p>In the schematics you can see the voltage regulator in the top left. I use 12volt DC in, from an old PC power supply. Which I regulate to 9 volts.</p>
<p>The 4093 contains four NAND gates with Schmidt triggers, and I use two of them. One controls the pitch of the sound, and the other controls the first one, by turning it on and off, so you get kind of an arpeggio. You can also turn that on and off with SW1.</p>
<p>The 4040 is a frequency divider, that is fed the output of the tone oscillator, and then each of the outputs of that is fed into two rotary switches. In that way you can mix together two octaves at the same time, getting a richer sound.</p>
<p>Most of this project was inspired by the book &#8220;Handmade electronic music&#8221;, by Nicolas Collins.</p>
<p><object width="480" height="390"><param name="movie" value="http://www.youtube.com/v/U517qSgJUKc?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/U517qSgJUKc?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="390"></embed></object></p>
<p>If you have any questions, or suggestions for improvements, please drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2011/04/bass-synth-work-in-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first commissioned work</title>
		<link>http://blog.gregerstoltnilsen.net/2011/03/my-first-commissioned-work/</link>
		<comments>http://blog.gregerstoltnilsen.net/2011/03/my-first-commissioned-work/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 18:48:17 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=76</guid>
		<description><![CDATA[At the last half of 2010, I was contacted by one of the professors at the department of music technology at NTNU, to do a work for them, and I gladly accepted. They wanted some sort of permanent installation that would make their hallways a bit more interesting, and they had previously seen one of my <a href='http://blog.gregerstoltnilsen.net/2011/03/my-first-commissioned-work/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>At the last half of 2010, I was contacted by one of the professors at the <a href="http://www.ntnu.edu/music">department of music technology at NTNU</a>, to do a work for them, and I gladly accepted.</p>
<p>They wanted some sort of permanent installation that would make their hallways a bit more interesting, and they had previously seen one of my prints from the &#8220;Wasted time&#8221; project, and so I used that as a basis when I started thinking.</p>
<div id="attachment_78" class="wp-caption alignright" style="width: 310px"><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/sollog_2009-03-27_11_49_01.png"><img class="size-medium wp-image-78  " title="&quot;Wasted time, 2009-03-27 11:49:01&quot;" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/sollog_2009-03-27_11_49_01-300x210.png" alt="" width="300" height="210" /></a><p class="wp-caption-text">&quot;Wasted time, 2009-03-27 11:49:01&quot;</p></div>
<p>I also wanted to do something that was tightly connected with the department, and what they do, so sound would have to be, in some way, an element in the work.</p>
<p>As the work was to be permanent, and is to be there for a long time, I wanted to make something that would need little to no maintenance, and not have the risk of stop working in some way. It should also not be to obtrusive, since people will need to walk past it every day, and I don&#8217;t want it to end up be an annoyance to the people who use the premises. With that in mind, I decided early on that I wanted to make some sort of generative prints, and started checking out possibilities at a prints shop. The choice I made was to make prints on acrylic plates.</p>
<p>I went to the location, and after deciding where I wanted the plates to hang, when they were done, I recorded the ambient sound in the hallways, with microphones placed at the spots where the pictures would be. The sound was then cut to find some interesting segments and then normalized. I then used the sound as data for drawing curves, circles and lines. This was done with utilizing the language <a href="http://processing.org/">Processing</a> and the library <a href="http://code.compartmental.net/tools/minim/">minim</a>.</p>
<p>For more information you can read my more detailed <a href="https://docs.google.com/document/d/1aLNXwlwr5G3CmL0Zdk0h5lXJ5vGxb2A06BYhYWp8WOI/edit?hl=en_GB&amp;authkey=COqVsroN#">technical description of the work</a>.</p>
<p><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_5997.jpg"><img class="size-medium wp-image-82 alignleft" title="D2C_5997" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_5997-201x300.jpg" alt="" width="201" height="300" /></a></p>
<p><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_6056.jpg"><img class="alignleft size-medium wp-image-83" title="D2C_6056" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_6056-201x300.jpg" alt="" width="201" height="300" /></a><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_6090.jpg"><img class="alignleft size-medium wp-image-85" title="D2C_6090" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2011/03/D2C_6090-201x300.jpg" alt="" width="201" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2011/03/my-first-commissioned-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pedals for Ableton Live</title>
		<link>http://blog.gregerstoltnilsen.net/2010/09/pedals-for-ableton-live/</link>
		<comments>http://blog.gregerstoltnilsen.net/2010/09/pedals-for-ableton-live/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 11:23:53 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Concert]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=56</guid>
		<description><![CDATA[For a concert later this year, a friend is gonna use Ableton Live to play some sounds, while also playing other instruments, and so he wanted to be able to control Live with his feet. Ableton Live is very nice, control wise, in that it is easy to map keys on the keyboard to do <a href='http://blog.gregerstoltnilsen.net/2010/09/pedals-for-ableton-live/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>For a concert later this year, <a title="Hands up Silve Space Suit" href="http://www.myspace.com/handsupsilverspacesuit">a friend</a> is gonna use Ableton Live to play some sounds, while also playing other instruments, and so he wanted to be able to control Live with his feet. Ableton Live is very nice, control wise, in that it is easy to map keys on the keyboard to do almost anything, and also that you can easily switch over to a mode where two rows of keys map up to a little more than one octave on a musical keyboard.</p>
<div id="attachment_57" class="wp-caption alignnone" style="width: 410px"><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/IMG_9244.jpg"><img class="size-full wp-image-57 " title="Pedal switches" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/IMG_9244.jpg" alt="The switches for each pedal" width="400" height="300" /></a><p class="wp-caption-text">The switches for each pedal</p></div>
<p>Having some pedals from old organs laying around, we decided they would be ideal for the physical part of the interface. And as they, on the lowest level just consist of one full octave of switches, the easiest thing was just to make it work like a keyboard. Mapping the &#8220;white&#8221; pedals to &#8220;asdfghjk&#8221;, and the &#8220;black&#8221; to &#8220;wetyu&#8221;.</p>
<p>I ripped the controller board out of an old USB keyboard, and used a multimeter in continuity mode to find out which pins matched the keys we wanted. Then it was just a matter of solder two wires from each of the pedal switches to the right pins on the controller card. Since some keys shared pins, we also matched those up, and connected the matching pins, to reduce the clutter.</p>
<div id="attachment_58" class="wp-caption alignnone" style="width: 410px"><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/IMG_9245.jpg"><img class="size-full wp-image-58 " title="Finished" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/IMG_9245.jpg" alt="The pedals all connected to the keyboard controller" width="400" height="300" /></a><p class="wp-caption-text">The pedals all connected to the keyboard controller</p></div>
<p>Now it is just a matter of planning and rehearsing, finding out what sounds to map to what pedal. Having the ability in Ableton Live, to also have different trigger modes on the sounds makes it a very nice program for live performances, but I guess that was the whole idea of the software, so it&#8217;s not surprising.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2010/09/pedals-for-ableton-live/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Viscount c.100 volume pedal</title>
		<link>http://blog.gregerstoltnilsen.net/2010/09/the-viscount-c-100-volume-pedal/</link>
		<comments>http://blog.gregerstoltnilsen.net/2010/09/the-viscount-c-100-volume-pedal/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 14:50:46 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=45</guid>
		<description><![CDATA[Just a small update on the organ I have been gutting. I have found out a lot, and will write some more about it real soon. I just wanted to write some words on this recent find, as I think it is a bit cute. Earlier today I took the whole organ apart, to save <a href='http://blog.gregerstoltnilsen.net/2010/09/the-viscount-c-100-volume-pedal/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<div id="attachment_48" class="wp-caption alignleft" style="width: 370px"><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/pedal.jpg"><img class="size-full wp-image-48 " title="Viscount c.100 volume pedal" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/pedal.jpg" alt="Viscount c.100 volume pedal" width="360" height="301" /></a><p class="wp-caption-text">Viscount c.100 volume pedal</p></div>
<p>Just a small update on the organ I have been gutting.</p>
<p>I have found out a lot, and will write some more about it real soon. I just wanted to write some words on this recent find, as I think it is a bit cute.</p>
<p>Earlier today I took the whole organ apart, to save some room in my studio, and was just trying to figure out the volume pedal&#8217;s resistance and stuff, for use with a guitar or something, maybe. Anyway, using my multimeter to measure the leads from the pedal didn&#8217;t give me any clues, so I opened it up.</p>
<p>Instead of the potentiometer I expected to find, the makers have used a small light bulb, and a light dependent resistor in a small room under the pedal. When you move the pedal, a plate divides the room more or less, and thus letting more or less light in on the LDR. Not very advanced, and not a new concept (to me), but I thought it funny that such a solution was used here.</p>
<div id="attachment_47" class="wp-caption alignnone" style="width: 610px"><a href="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/lampldr.jpg"><img class="size-full wp-image-47" title="Lamp and LDR" src="http://blog.gregerstoltnilsen.net/wp-content/uploads/2010/09/lampldr.jpg" alt="Lamp and LDR in the Viscount c.100 volume pedal" width="600" height="304" /></a><p class="wp-caption-text">Lamp and LDR in Viscount c.100 volume pedal</p></div>
<p>I have also figured out, in theory, how to hook up the spring reverb, and hopefully that will be something I will write about in my next post, as I am gonna build a small effect box to have it in. The plan is to make it both usable as a guitar effect, and as an insert effect in a mixer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2010/09/the-viscount-c-100-volume-pedal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contour tracing in Processing</title>
		<link>http://blog.gregerstoltnilsen.net/2010/07/contour-tracing-in-processing/</link>
		<comments>http://blog.gregerstoltnilsen.net/2010/07/contour-tracing-in-processing/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 23:32:58 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tracing]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/?p=21</guid>
		<description><![CDATA[I recently read the book Aarons code, and with that the thought of writing some contour tracing functions came up. When I also, a few days later got an idea for a project, I got to it. Do searches on Google pointed me in the direction of the blob extraction algorithm that OpenCV uses, and <a href='http://blog.gregerstoltnilsen.net/2010/07/contour-tracing-in-processing/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I recently read the book <a href="http://www.pamelamc.com/html/aaron_s_code.html">Aarons code</a>, and with that the thought of writing some contour tracing functions came up. When I also, a few days later got an idea for a project, I got to it. Do searches on Google pointed me in the direction of the blob extraction algorithm that OpenCV uses, and so I found <a href="http://www.google.com/url?sa=t&amp;source=web&amp;cd=1&amp;ved=0CBIQFjAA&amp;url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.95.6330%26rep%3Drep1%26type%3Dpdf&amp;ei=2U4yTOiAN8-aOKqWuf4B&amp;usg=AFQjCNFIL2Khb3lvHsGa-tToddlwnXJ2Fg&amp;sig2=cVSm-okTlv-5lFtGil7Snw">&#8220;A linear-time component labeling algorithm using contour tracing technique&#8221;</a>.</p>
<p>Lately I have also started looking into using NetBeans as an IDE for programming with the Processing library, so I decided that I would implement the algorithm in the paper in java, using Processing.</p>
<p>The code is provided below, and is provided as is. It can probably be optimized a bit, and/or rewritten to be better. But for now it works for me.</p>
<p>If you have any suggestions to changes, or you use it, please leave a comment so I can check it out.</p>
<pre class="brush: java; title: ; notranslate">
 /*
 * An implementation of
 * «A linear-time component labeling algorithm using contour tracing technique»
 * by Fu Chang, Chun-Jen Chen, and Chi-Jen Lu
 *
 * Written in Java for use with the Processing (www.processing.org) library.
 *
 * Code written by Greger Stolt Nilsen
 * (gregersn@gmail.com / http://gregerstoltnilsen.net)
 * Copyright 2010, Greger Stolt Nilsen
 *
 * Code is provided «as is», and no warrenty is given. Use at your own risk.
 *
 * This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.

 */
/*
 * Create a new instance with:
 * ComponentFinder finder = new ComponentFinder(this, image);
 * where &quot;image&quot; is the PImage (or PGraphics) to be traced.
 * use the find()-function, to get all the contours in the contours arraylist.
 * Each contour is by itself an ArrayList of PVectors.
 *
 * render_blobs() will return a PImage object that is a rendering of all the
 * blobs in the traced image.
 *
 * The Image to be traced need to be black (0x000000) objects on white background.
 * So use the threshold-filter to get to that.
 *
 * Also, unless the outer border of pixles is white, the finder will hang.
 */

package ComponentFinder;

import processing.core.*;
import java.util.ArrayList;

public class ComponentFinder
{
    PApplet parent;
    public ArrayList contours;
    int[] inout;
    int[] L;
    PImage I;
    int C;

    // An array with the 8 direction coordinates (x1, y1, x2, y2... x8, y8)
    int cd[] = {1, 0, 1, 1, 0, 1, -1, 1, -1, 0, -1, -1, 0, -1, 1, -1 };

    public ComponentFinder(PApplet p, PImage img)
    {
	parent = p;
	I = img;
	C = 1;
	L = new int[I.width*I.height];

    }

    int getNumContours()
    {
	if(contours != null)
	    return contours.size();
	else return 0;
    }

    public int find()
    {
		// Initialize the blob map to zero.
		for(int i = 0; i &lt; I.width*I.height; i++)
		{
		    L[i] = 0;
		}

		// Make a new array list to store each contour.
		contours = new ArrayList();

		C = 1;

		int pos = I.width; // Start analyzing the image at the second line

		I.loadPixels();

		// Label the first line as blank pixels.
		for(int x = 0; x &lt; I.width; x++)
		    L[x] = -1;

		for(int y = 1; y &lt; I.height; y++)
		{
		    for(int x = 0; x &lt; I.width; x++)
		    {
			if(L[pos] == 0) // Only process unlabeled pixels
			{
			    if(((I.pixels[pos]&amp;0xffffff) != 0x000000))
			    {
				// White pixel
				L[pos] = -1;
			    }
			    else if(((I.pixels[pos]&amp;0xffffff) == 0x000000))
			    {
				if((I.pixels[pos-I.width]&amp;0xffffff) != 0x000000)
				{
				    // If the pixel above is a white pixel,
				    // then this is the start of an outer contour
				    L[pos] = C;
				    // Start tracing an outer contour
				    contours.add(contourTrace(new PVector(x, y), 0, C));
				    C++;
				}
				if(((I.pixels[pos+I.width]&amp;0xffffff) != 0x000000) &amp;&amp; (L[pos+I.width] == 0))
				{
				    // If the pixel below is a white pixel, then it is the start of an
				    // inner contour, and we get the id for the outer contour
				    // then start tracing the inner contour
					int l;
					if(L[pos] != 0 ) l = L[pos];
					else l  = L[pos-1];

					if(L[pos] != 0) L[pos] = l;
				        contours.add(contourTrace(new PVector(x, y), 1, l));
				}
				if(L[pos] == 0) if(L[pos-1] &gt; 0) L[pos] = L[pos-1];
			    }
			}
			pos++;
		}
	}
	I.updatePixels();
	return getNumContours();
    }

    // Traces a countour at the given pixel S,
    // r is set to 0 for outer contours, and 1 for inner contours.
    // c is the label to give the contour
    ArrayList contourTrace(PVector S, int r, int c)
    {
	int next = 8;
	ArrayList cont = new ArrayList(32);
	PVector current = new PVector();
	cont.add(S.get());
	if(r == 0) // Outer contour
	    next = Trace((PVector)cont.get(cont.size()-1), 7, c);
	else if(r == 1) // Inner contour
	    next = Trace((PVector)cont.get(cont.size()-1), 3, c);

	if(next == 8) return cont; // The pixel is isolated.

	PVector T = new PVector(S.x + cd[next&lt;&lt;1], S.y + cd[(next&lt;&lt;1)+1]);
	cont.add(T.get());

	next = Trace((PVector)cont.get(cont.size()-1), (next+6)%8, c);

	if(next == 8) return cont;

	while(true)
	{

	    current.x = (float)((PVector)cont.get(cont.size()-1)).x + cd[(next&lt;&lt;1)%16];
	     current.y = (float)((PVector)cont.get(cont.size()-1)).y + cd[((next&lt;&lt;1)+1)%16];
		next = Trace(current, (next+6)%8, c);

		// Check if we are back at start position
	    if((current.x == S.x) &amp;&amp; (current.y == S.y) &amp;&amp; (current.x + cd[next&lt;&lt;1] == T.x) &amp;&amp; (current.y + cd[(next&lt;&lt;1)+1] == T.y))
	    {
		return cont;
	    }
	    else
	    {
		cont.add(current.get());
	    }
	}
    }

    int Trace(PVector P, int n, int c)
    {
		for(int i = 0; i &lt; 8; i++)
		{
		    // if pixel at position n+i is black, return n+i
		    PVector ni = new PVector(P.x+cd[((i+n)%8)*2],
					    P.y+cd[((i+n)%8)*2+1]);

			if((I.pixels[(int)(ni.y)*I.width+(int)(ni.x)]&amp;0xffffff) == 0x000000)
		    {

				L[(int)(ni.y)*I.width+(int)(ni.x)] = c;
				return (i+n)%8;
		    }
		    // if not, mark with a negative number
		    else
		    {
				if(L[(int)(ni.y)*I.width+(int)(ni.x)] == 0)
				    L[(int)(ni.y)*I.width+(int)(ni.x)] = -1;
		    }
		}
		return 8; // Should only happen for isolated pixels.
    }

    public PImage render_blobs()
    {
		PImage blobs = parent.createImage(I.width, I.height, PApplet.RGB);
		blobs.loadPixels();
		parent.colorMode(PApplet.HSB);
		for(int i = 0; i &lt; L.length; i++)
		{
		    if(L[i] &gt; 0)
				blobs.pixels[i] = parent.color(PApplet.map(L[i], 1, C, 0, 255), 255, 255);//|0xff000000;
		    if(L[i] == -1)
				blobs.pixels[i] = parent.color(0, 0, 255);
		    if(L[i] == -2)
				blobs.pixels[i] = parent.color(0, 0, 0);
		    if(L[i] == 0)
				blobs.pixels[i] = parent.color(0, 0, 128);
		}
		blobs.updatePixels();
		return blobs;

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2010/07/contour-tracing-in-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gutting an old transistor organ</title>
		<link>http://blog.gregerstoltnilsen.net/2010/07/gutting-an-old-transistor-organ/</link>
		<comments>http://blog.gregerstoltnilsen.net/2010/07/gutting-an-old-transistor-organ/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:31:09 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Sound]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/tmp/wordpress/?p=11</guid>
		<description><![CDATA[I&#8217;ve had an old Viscount c.100 transistor organ standing around in my studio for quite a while, and I&#8217;ve finally come around to start gutting it. The goal is to learn a bit more about electronics, as well as try to be able to use the spring reverb, the rhythm generator and the pedals for <a href='http://blog.gregerstoltnilsen.net/2010/07/gutting-an-old-transistor-organ/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had an old Viscount c.100 transistor organ standing around in my<br />
studio for quite a while, and I&#8217;ve finally come around to start gutting<br />
it. The goal is to learn a bit more about electronics, as well as try to<br />
be able to use the spring reverb, the rhythm generator and the pedals<br />
for something else.</p>
<p><a title="D7C_9061.jpg by gregersn, on Flickr" href="http://www.flickr.com/photos/gregersn/4720679536/"><img src="http://farm5.static.flickr.com/4065/4720679536_a3e0cbfa09.jpg" alt="D7C_9061.jpg" width="333" height="500" /><br />
</a></p>
<p>What I am thinking with the reverb is to put it in it&#8217;s own box, so that<br />
it can be used as an insert effect on mixers, or as a pedal effect for<br />
guitar.</p>
<p>The rhythm section can be used for what it is for, but I want to build<br />
it into a smaller box, so it is portable and can be used in different<br />
situations. Also, since I have figured out it gates the bass pedals, I<br />
will try and add connections so it can be used as a trigger/gate for<br />
other stuff.</p>
<p>The pedals I will build into a box, with the oscillators so that it can<br />
be used on it&#8217;s own as a foot driven bass keyboard for live performances.</p>
<p>I am self thought when it comes to electronics, and I have not studied<br />
it very well, but I do know some basics. So this is a challenge, but a<br />
good one.</p>
<p>In lack of a proper oscilloscope I am using <a href="http://xoscope.sourceforge.net/">xoscope</a> with a <a href="http://www.ladyada.net/library/equipt/diyaudioprobe.html">sound card probe</a>.</p>
<p>More pictures, and some sketches will come when I figure out something<br />
useful, and have organized my notes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2010/07/gutting-an-old-transistor-organ/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Picasa face detection to Lightroom</title>
		<link>http://blog.gregerstoltnilsen.net/2010/07/picasa-face-detection-to-lightroom/</link>
		<comments>http://blog.gregerstoltnilsen.net/2010/07/picasa-face-detection-to-lightroom/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:30:54 +0000</pubDate>
		<dc:creator>Greger</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.gregerstoltnilsen.net/tmp/wordpress/?p=6</guid>
		<description><![CDATA[I have written a Perl script to move data gathered from Picasa's face detection function, into the XMP metadata of my NEF files, to be used in Lightroom.]]></description>
			<content:encoded><![CDATA[<p>I do most of my photo editing, and picture organizing, in Adobe Photoshop Lightroom. Since I now how over forty thousand pictures from miscellanous events and concerts, and everything else, I like to tag people in pictures, so I can find them again, easily, if anyone asks.</p>
<p>Picasa 3 came with a face detection feature, which scans through all the pictures in your library, and tries to find people with some fancy algorithm. You can then add a name to the face, and easily see all pictures you have with that person in it. Almost. It doesn&#8217;t find a face in every situation, so it is not perfect, but it is a good start.</p>
<p>However, Picasa does not store the data about people in the files metadata. You can trick it in there, but since I work with RAW files (NEF), and Picasa doesn&#8217;t use XMP for metadata, that is not a good way to do it.</p>
<p>With a bit of reasearch, I found out that in every directory where there are pictures with found faces, Picasa stores a file ( .picasa.ini) that contains information about what picture file contains faces, where in the file there is a face, and what contact that is hooked up to. Picasa also stores an XML file with all the contacts in them.</p>
<p>Using that I wrote a small Perl-script that gets all the contacts out of the XML-file, scans through the current directory for the .picasa.ini file, matches contacts with that, and stores the new data in XML metadata with the file.</p>
<p>Before using the script, you need to change some variables to point to the right contacts file and such. You also need the XML library for Perl, and the Perl Exiftool-library installed.</p>
<p>The script has only been tested in Windows 7, with Cygwin.</p>
<p>The procedure goes as follow:</p>
<ol>
<li>In Picasa, do the face tagging. Check the picasa website for help on that.</li>
<li>In Lightroom, make sure you select all the pictures you want to update, and write all the metadata to files. That&#8217;s from the metadata menu.</li>
<li>Go to the folder you have some pictures with people in it and run the Perl script.</li>
<li>Open Lightroom again, select the pictures, and choose to read metadata from files.</li>
</ol>
<p>It seems to be working okay now, but I take no responsibility for damages it may do to your pictures if you try it. Make sure you have a backup first!</p>
<p>To run the script recursively I use the command:</p>
<pre class="brush: plain; title: ; notranslate"> find . -name \.picasa\.ini -execdir ~/scriptlocation/faceextract.pl \;</pre>
<p>The script is available on<a title="github" href="https://github.com/gregersn/faceextract"> github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gregerstoltnilsen.net/2010/07/picasa-face-detection-to-lightroom/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

