Friday, November 28, 2014

Afbeeldingen bij Volkskrant stuk van 29 nov 2014

Als aanvulling op het stuk in de Volkskrant over de zelfrichtende zonnebloem wilde ik hier wat foto's laten zien, het elektrische schema en een kort filmpje.
Daarnaast zal ik een afbeelding plaatsen die ik zelf als zonnewijzer heb gebruikt. Ik heb een formule van Wikipedia gebruikt om de hoek tussen de uren te berekenen. Ik heb het één keer getest en toen was de afwijking ongeveer tien minuten wat ik aanvaardbaar vond.
Vragen zijn altijd welkom.



In de bovenstaande video zie je eerst hoe de bloem reageert als er niks van stabilisatie is. De motor draait op vol vermogen en schiet daardoor steeds te ver door. Hij beweegt daardoor heel wild. Daarna heb ik een kunstmatige vertraging toegepast door de motor steeds maar heel kort (10 ms) aan te laten en vervolgens weer uit te zetten.

Het initiële idee voor het gehele elektrische schema.
De weerstand van de LDR's is echter te groot om nog voldoende stroom te krijgen

Twee LDR's met weerstand, de feitelijke sensoren.


Het uiteindelijke elektrische schema.
Het sensor deel (boven) is nog hetzelfde maar de spanning gaat nu naar de Arduino.
De Arduino beslist dan welke transistoren in het onderste deel open mogen (pretty nice)
10 en 11 of 12 en 13 gaan tegelijk open.

Schakeling in test opstelling. Het bovenste breadboard bevat de LDR's,
de onderste de vier transistoren die de stroomrichting van de motor besturen



Definitieve opstelling in een houten doos





Zonnewijzer die onder de bloem geplaatst kan worden. Of gewoon op je vensterbank.
12 uur moet naar het zuiden gericht worden. Geschikt voor 520 NB en wintertijd.

Saturday, November 1, 2014

Foto's en Video's bij mijn Whack-A-Mole stukje uit de Volkskrant



Dit zijn wat foto's die ik gemaakt heb tijdens het maken van het Whack-A-Mole spel, of eigenlijk, Mep-Een-Vlieg waarover ik een stukje heb geschreven in de Volkskrant van 1 november 2014.

Als je geen papieren versie te pakken hebt gekregen is het artikel te vinden via de Volkskrant website of bijv. via Blendle.

Mocht iemand zelf een Mep-Een-Vlieg Spel willen maken, de foto's hieronder geven al een goed beeld van wat je moet doen. Als je nog vragen hebt stel ze dan vooral.

Allereerst een korte video van dochterlief terwijl ze het spel probeert.




Close up van mijn tekenkunst
Bovenaan het zilverfolie een groene LED
die door de folie prikt om het te verbinden



Enthousiast uittesten (maar echt hoor)

Serieus, ze vond het heel leuk,
maar het was 7:30 's ochtends

Binnenkant van de doos.
Boven in beeld de speaker
Schematisch schema

ENGLISH
These are some pictures I made during the making of my own Whack-A-Mole (Fly in this case).
I made this project for my article in de Volkskrantof 1st november 2014.
Questions are always welcome.

Thursday, October 23, 2014

Zelfsturende Auto (foto's bij het Volkskrant stuk)

(English below)
Op zaterdag 3 oktober verscheen in De Volkskrant mijn eerste bijdrage in 'De Maakbare Wereld' in de zaterdag Sir Edmund katern. (te vinden op de Volkskrant website of bijv Blendle de eerste zoveel artikelen kun je gratis lezen)
Hier heb ik kort uitgelegd hoe ik een afstandsbestuurbare auto met mijn laptop kon besturen.
Een volgende stap is natuurlijk dat er geen persoon meer aan te pas komt. En ik heb daar al een groot deel van geknutseld, maar nog geen tijd gehad om de puntjes op de i te zetten.

Wat ik in elk geval wilde delen waren de foto's die ik gemaakt van tijdens het werken aan de auto. De foto's waar de toffe tekeningen op gebaseerd die gemaakt zijn door Bier & Brood.

De auto en wat belangrijke werkspullen

Testen waar spanning op gezet moet worden



Draden gesoldeerd in AB en via wat transistoren (kleine zwarte dingen) op
een breadboard (witte ding) naar de Arduino (blauw ding)

Als iemand specifieke vragen heeft, stel ze. Dit is niet een enorm ingewikkeld knutsel project en zeker niet duur. In dit geval is de Arduino het meest kostbaar en een autootje is natuurlijk niet gratis.

Het lastigste is in zo'n geval het uittesten hoe de afstandsbediening nu precies werkt. En dat testen heb ik gewoon gedaan door te kijken hoe zit de batterij aangesloten (waar gaan de plus en min heen) en gewoon wat met de 5 Volt uitgang van de Arduino en twee draden proberen. Kleine kans dat je iets stuk maakt met die 5 Volt, want de batterij die er inzat was een 9V blok.

En gaat er een keer iets stuk dan heb je ook iets geleerd. Gebruik dus spullen waar bij het niet erg is dat ze stuk gaan.

Misschien een goeie tip voor Sinterklaas: vraag een soldeerbout en wat weerstanden :)


ENGLISH (very short summary)

I wrote my first newspaper article about controlling a RC car with my laptop. These are some pictures I made while making the project.
If you have any questions, ask them.

Sunday, August 10, 2014

Ebola Outbreak 2014

Ever since I first heard about the Ebola virus I have found it very terrifying. Who wouldn't with high infection chances and survival rates being low and no cure (apart from the stories about a 'secret medicine' in the US only tested on animals). Since March news items regularly hit the news of an Ebola outbreak in West Africa. Countries that are hit the worst are Guinea, Liberia and Sierra Leone.

Source: Wikipedia


But news items usually state the total number of casualties so far or some recent events, but they somehow don't manage to show me how serious the situation is. So I went to the WHO site on the subject. Here they have posted news updates. So I went through them all to get the overview myself.


Countries in Western Africa involved in Ebola outbreak
Below is, as at the time of writing, the most recent overview by the WHO. You can see that luckily Nigeria still hasn't had that many cases, but the other countries are not that lucky. There were reports about cases in Mali, but they were tested negative.


New (1)ConfirmedProbableSuspectTotals
Guinea
Cases03551337495
Deaths42311333367
Liberia
Cases38148274132554
Deaths1213211745294
Nigeria
Cases407613
Deaths10202
Sierra Leone
Cases266313848717
Deaths12259345298
Totals
Cases681 1344521931 779
Deaths2962228653961
1. New cases were reported between 5 and 6 August 2014.
source: WHO aug 8 2014

This of course only tells you part of the story. The Wikipedia on the 2014 outbreak is very elaborate on the matter and it has a nice graph of the totals. To get an impression how different countries are doing I put the data I took from the WHO site in a graph.


In this graph you see the total number of cases. That includes confirmed, deaths and suspected cases.
The graph tells a sad story of course. in Guinea the outbreak started and slowly the number of cases is increasing. But for Sierra Leone and Liberia it looks a lot grimmer. The number of cases is really exploding, so let's hope they are able to stop this soon.

I choose to use circles in this graph and not a continuous line. It seems more transparent. The data isn't continuous in any way. The information comes with a couple of days apart, it's changed constantly when tests are negative and of course people come in whole numbers. So in Liberia in April there were some suspected cases they turn out not to be due to Ebola. In result the total number was lower in May.

Death rates are always really high with Ebola and this outbreak is no exception. Guinea: 74%, Liberia: 53% and Sierra Leone: 41%. Those number could go up I guess since there some time between showing signs of the virus and when people pass away.



Monday, July 7, 2014

Reducing the Number of Colors (Part I)

In my last post I discussed a way to reduce the number of colors in grayscale image. So the natural step was to proceed to a color image. Let's start with a nice color image.




The color image is just a collection of a red, a green and a blue image.


The Ignorant Approach


The first thing I tried, just to see what would happen, was to try the algorithm I made for the grayscale image. That means repeating the process for the individual channels and later merging the result.
That works, but it doesn't give the result I am really looking for.


For some colors this approach works. The sky is a nice color blue, some bright yellow accents on the plane come out as I wanted, but some color like on the right wing seem wrong.
What the program found were 6,6 and 7 peaks for the color channels. That means that if a certain value of blue is very dominant that value will be picked. But the area that belongs to that color might not be purely blue.

Similar But Different

Here's an example of 6 colors with the same maximum blue value of 255, but with different red and green values.

Square with different RGB values, but the same blue value.

You can imagine that one of these colors is not found as a dominant. If a certain color is found it has to give rise to a peak in he histogram of all three colors.


The picture above is an example in two color dimensions, the x-axis representing green and the y-axis blue. The dots are both colors that occur in some image. But perhaps the one in the top is found in way more pixels then the one in the bottom. In the end the green value which is the same for both colors will be found probably. But the blue value of the lowest color might not be found. Every pixel with a color close to that bottom color will be assigned a green value that is correct, but the new blue value could be miles off.

3D RGB Space


For me the problem was beginning look a bit clearer, also a bit more difficult. When you look at all the colors that occur in an image there are thousands. Some are quite similar, like all those colors blue in the sky of our example image. Let's see what all these colors look like in the 3D RGB space.

3D RGB Space of the Spitfire image

What I have drawn here is all the pixels in the image placed in the RGB space. Easily understandable points are (0,0,0) which is black in the front and (255,255,255) as white in the back. Along the diagonal axis are all the gray colors. Off diagonal RGB values are the other colors, and you can see some groups, and a lot of empty space. What you can't see how many identical RGB points there are, and how many of are all alone.
That is why I made the same image but here I changed the size of the circles to show how many pixels have that color.




We are looking at it from a different angle, but it shows one thing; there are a lot of blue pixels.

That's about as far as I've come right now. What I intend to do next is to find the regions of this image where a lot colors are found close together (like that blue area in the top). So this is similar to finding a peak in 1D histogram, but than more like finding a 3D peak (a blob with the highest density).
I am still thinking of what the best approach is going to be for this. 

Stay tuned!









Tuesday, July 1, 2014

Reducing the number of colors in an image

OK first all, one of my most favorite astronaut pictures showing Anna Lee Fischer. To me it looks it's from a movie or something, it's just that cool.

Anna Lee Fischer

Long story short, I was wondering if I could reduce the number of colors (the grays) in this picture. Just for fun and exercise. I could try an image/photo editor, but it's always more fun to do it yourself right.

I went to work in Matlab and to just show you the end result first (before all long boring programming details). Tadaa!

Only 5 grays left


How it's done

The main idea I had was finding the colors that are most dominant. We therefore look at the histogram of the image as shown below. Values run from 0 to 255 on the x-axis and the y-axis represents the number of occurrences of a certain gray value in the image.



Something I find strange are the very regular holes in the histogram where a certain gray value apparently never occurs. Apart from that it's not a smooth line, there are about 5 local maxima visible. 
How do we find those?

Finding the peaks

I first removed the holes by using the average of the gray values around it. After that I applied a Gaussian smoothing. Before I tell you about how I find the peaks I'll first show the result of smoothing and finding the peaks.


You can see that the line is now very smooth and there are small red lines to show where the peaks are found. I find it a very satisfactory result. It may seem like the first and last line are just a bit off, but that is only because the steps are integers and the lines are placed on the integers. So i.e. to me and you the peak should be at 18.7, but it is found at 19.

The short explanation of how the peaks are found is this. I let the program walk along the line until it reaches the top. That means the next position has a lower value instead of a higher value. After that we continue to find the valley, so look for a position where the next element is higher instead of lower. And we go back to finding the next peak. I'm only interesting in the peaks of course. I don't tell the program how many peaks there are, just to stop when it's at the end of the histogram. 

Changing the colors 

To create the new image I take the value of every pixel in the original image and look to which peak value it is closest. Then it is changed to that peak value with a preference to the lowest/darkest value. The original image was pretty noisy so you can see this in the end result. 

When you use this method you have no control over how many colors the end result will have. This can be an advantage or a disadvantage depending on your needs. But I like it that we don't put in any previous knowledge and the program itself finds the most dominant values.

I guess this whole process or parts of it has a name, but it was still nice to built myself from scratch.

I'll try how the program works with color images, which will need some adjustments.





Tuesday, June 24, 2014

Presidents in books

I just read about Ngram Viewer. A Google project where you can search for words of phrases in books Google has digitalized. Here I search for presidents of the United States, from FDR till Jimmy Carter. Non interactive picture: