During the past two years I’ve had the occasional pleasure of riding my motorcycles on race tracks.
While I’m still far away from being fast I really enjoy working on my riding.
This led me to considering different data recording and analysis solutions.
A bit down the line I realized that the GoPro cameras I already owned actually contain
a surprisingly good GPS unit recording data at 18hz.
To make things even better GoPro also documented their meta data format and even published
a parser for it on GitHub.
I was very curious how far I could get with that data and started to play around with it.
Many hours and experiments later I somehow ended up with my own analysis software and filters tuned for
the camera data.
For filtering the data I wrote a little library for kalman filters in TypeScript. The Kalman Filter book by Roger Labbe helped a lot in learning about the topic.
I highly recommend it if you want to dive into the topic yourself.
In addition to the obvious line plots of speed, acceleration and lean angles I also implemented a detailed map and
what I call a G Map.
The lap map shows the line, speeds, breaking points and g forces in a spatial context.
I especially like the shaded areas in the corners. They show the
lateral (distance from the line) and total (color of the area) forces at play.
Looking at the map is a quick way to gauge how close to the limit one is potentially riding in each of the corners.
The G-Map is a histogram of the G-Force acting on the vehicle over time.
It can be used to gauge how close to the limit a rider is riding.
Assuming a perfect world where vehicles have isotropic grip, the vehicle sufficient power and the
rider always operating it at the limit it would trace out a perfect circle, resembling the Circle of forces.
As you can see my example above is far away from that. It shows conservative riding, always staying within
the 1 g that warm track tires can easily handle. It also shows that I still have a lot to learn with regards
It also shows that the track in question has more right turns than left.
There is of course a lot more that can be done here.
The GoPro also has an accelerometer and gyro which could be integrated into the filters to yield
more accurate results.
The additional data would yield the actual lean angle which could then be used in combination with the
lateral acceleration to gauge the effectiveness of the body position/hangoff of the rider.
I also have another version of this running on a Raspberry PI coupled to an external GPS receiver.
This combination results in an all in one integrated data recording solution. One can simply connect to the
WiFi hotspot of the little computer onboard the vehicle and view the most recent sessions.
It’s rather nice because it doesn’t require the camera to be running all the time and is quite simple to use.
The drawback is that it requires fiddling together a bunch of hardware which I guess most people don’t want to deal with.
There are two things that need to be said here.
First off this is not a perfect solution and even if it was it couldn’t definitely
answer the question of how close to the limit the rider is. Factors like the track surface,
weight transfer and other shenanigans are not accounted for.
Secondly, this product and/or service is not affiliated with, endorsed by or in any way associated with GoPro Inc. or its products and services. GoPro, HERO and their respective logos are trademarks or registered trademarks of GoPro, Inc.
It’s been a while since the last release but I finally finished something again.
Noise tends to eject me from my focus and flow and sometimes noise canceling headphones just aren’t enough
to prevent it.
In those instances I often mask the remaining noise with less distracting pure noise.
There already are various tools for this purpose, so there isn’t really a strict need for another one.
I just wanted to have some fun and build something that does exactly what I want and looks pretty while doing it.
As a nice bonus it gave me an opportunity to play with some more recent web technologies.
I don’t expect this to be useful to particularly many people other than myself but that’s why it’s a spare time project. :)
One of the first lessons in astrophotography is that you better find a dark place,
far away from the lights of civilization if you want to take good pictures of the night sky.
Wouldn’t it be beautiful if it was possible to photograph the Milky Way in the middle
of a city?
I wanted to try.
Step by Step
I packed my camera onto my bike and rode into night to take a few photos.
This is what they looked like after I developed them using RawTherapee.
Straigh out of camera
When you take a picture of the night sky in a city this is about what you will get.
At least we can see Saturn and a few stars. Let’s try to peek through the haze.
The first step is to collect more light. The more light we capture with our camera
the easier it will be to separate the photons coming from the nebulae in the galactic center from
the noise. We can gather more light by capturing more photographs.
The only problem is of course that the stars are moving.
The stars are moving
We can fix this problem by aligning the images based on the stars. I used Hugin for this job.
The earth slowly turning
The next step is to combine (stack) all of the images into one.
The ground will look blurry because it moves but the stars will remain sharp.
I used Siril for this task.
Now this is where the magic happens. We remove the ground and stars from the image
and then blur it a lot.
All this image now contains is the light pollution. Let’s subtract1 it.
With all of the light pollution gone darkness remains.
Now we can amplify the faint light in the image, increase contrast and denoise.
Finally we add the recovered light back to one of the original images and apply some final tweaks.
Why this is possible
This is possible because of two main reasons.
Light pollution is the result of light being scattered (light bouncing of particles in the air) in the air.
Unlike for instance dense smoke, light pollution does not block the light from the glowing gas clouds of the Milky Way.
This means that the signal is still there just very weak compared to the city lights.
The other reason is that the light pollution, especially higher above the horizon becomes more and more even.
That’s the property that allows us to separate it from the more focused light of the stars and nebula using a high pass filter.
Settings & Equipment
In case you are curious about the equipment and settings used:
Nikon D810, Samyang 24/1.4 @ 2.8, ISO 100, 9 pictures @ 20s, combined using winsorized sigma clipping.
The result is definitely noisy and not of the highest quality but still it amazes me, that this is even possible.
A consumer grade camera and free software can reveal the center of our home galaxy behind the bright haze of city lights,
showing us our place in our galaxy and the the universe beyond.
I’m curious how much farther I can push this technique with deliberately chosen framing, tweaked settings, more exposures and maybe a Didymium filter.
If you want to learn about astrophotography in general I recommend you to read lonelyspeck.com.
Ian is a much better writer than I will ever be and he has written a lot of great articles.
1: In practice you want to use grain extract/merge here since subtraction in most graphics software clips negative values to zero.
In this brave new world of alternative facts the people need the tools to tell
true from false.
Well either that or maybe I was just playing with JPEG encoding and some of that crossed
over into my little web based photo forensics tool in the form of some new tools. ;)
The JPEG file format contains a section for comments marked by 0xFFFE (COM).
These exist in addition to the usual Exif, IPTC and XMP data.
In some cases they can contain interesting information that is either not available
in the other meta data or has been stripped.
For instance images from wikipedia contain a link back to the image:
This is probably the most interesting bit of information revealed by this new tool
A basic understanding of how JPEG works can help in understanding this tool so I will try to give you some intuition using the noble art of hand waving.
If you already understand JPEG you should probably skip over this gross oversimplification.
JPEG is in general a lossy image compression format. It achieves good compression rates
by discarding some of the information contained in the original image.
For this compression the image is divided in 8x8 pixel blocks.
Rather than storing the individual pixel values for each of the 64 pixels in the block directly JPEG saves how much they are like one of 64 fixed “patterns” (coefficients).
If these patterns are chosen in the right way this
transform is still essentially lossless (except for rounding errors)
meaning you can back the original image by combining these patterns.
Now that the image is expressed in terms of these patterns JPEG can selectively discard some of the detail in the image.
How much information about which pattern is discarded is defined in a set of tables that is stored inside of each JPEG image.
These tables are called quantization tables.
Example quantization table for quality 95
There are some suggestions in the JPEG standard on how to calculate these tables for a given quality value (1-99). As it turns out not everyone is using these same tables and quality values.
This is good for us as it means that by looking at the quantization tables used in a JPEG image we can learn something about the device that created the JPEG image.
Identifying manipulated images using JPEG quantization tables
Most computer software and internet services use the standard quantization tables. The very notable exception to this rule are Adobe products, namely Photoshop. This means that we can detect images that have been last saved using Photoshop just by looking at their quantization tables.
Many digital camera manufacturers also have their own secret sauce for creating quantization tables.
Meaning that by comparing the quantization tables between different images taken with the same type of camera and setting we can identify whether an image was potentially created by that camera or not.
Automatic identification of quantization tables
Forensically currently automatically identifies quantization tables that have been created according to the standard. In that case it will display Standard JPEG Table Quality=95.
It does also automatically recognize some of the quantization tables used by photoshop.
In this case it will display Photoshop quality=85.
I’m missing a complete set of sample images for older photoshop versions using the 0-12 quality scale. If you happen to have one and would be willing to share it please let me know.
If the quantization table is not recognized it will output Non Standard JPEG Table, closest quality=82 or Unknown Table.
JPEG images contain tables that specify how the image was compressed. Different software and devices use different quantization tables therefore by looking at the quantization tables we can learn something about the device or software that saved the image.
In addition to the quantization tables the order of the different sections (markers) of a JPEG image also reveal detail about it’s creation. In short images that were created in the same way should in general have the same structure. If they don’t it’s an indication that the image may have been tampered with.
Sometimes images contain (meta) data in odd places.
A simple way to find these is to scan the image for sequences of sensible characters. A traditional tool to do this is the strings program in Unix-like operating systems.
For example I’ve found images that have been edited with Lightroom that contained a complete xml description of all the edits done to the image hidden in the XMP metadata.
Facebook Meta Data
When using this tool on an image downloaded from facebook one will often find a string like
From what I can tell this string is present in images that are uploaded via the web interface.
A quick google does not reveal much about it’s contents. But it’s presence is a good indicator that an image came from facebook.
I might add a ‘facebook detector’ that looks for the presence & structure of these fields in the future.
Poke around using these new tools and see what you can find! :)
In essence PCA offers a different perspective on the data which allows us to find outliers more easily.
For instance colors that just don’t quite fit into the image will often be more apparent
when looking at the principal components of an image.
Compression artifacts do also tend to be far more visible, especially in the
second and third principal components. Now before you fall asleep, let me give you an example.
This is a photo that I recently took:
To the naked eye this photo does not show any clear signs of manipulation.
Let’s see what we can find by looking at the principal components.
First Principal Component
Still nothing suspicious, let’s check the second one:
Second Principal Component
And indeed this is where I have removed an insect flying in front of the lens
using the inpainting algorithm algorithm (content aware fill in photoshop speak) provided by G’MIC.
If you are interested Pat David has a nice tutorial on how to use this
in the GIMP.
Resistance to Compression
This technique does still work with more heavily compressed images.
To illustrate this I have run the same analysis I did above on the smaller & more compressed
version of the photo used in this article rather than the original.
As you can clearly see the anomaly caused by the manipulation is still present
and quite clear but not as clear as when analyzing a less compressed version of the image.
You can also see that the PCA is quite good at revealing the artifacts caused by (re)compression.
If you found this interesting you should consider reading my article Black and White Conversion using PCA
which introduces a tool which applies the very same techniques to create beautiful black and white conversions of photographs.
If you want another image to play with try the one in this
by Neal Krawetz is interesting. It can be quite revealing. :)
I have been hacking on my photo forensics tool lately.
I found a
that suggested that performing PCA on the colors of an image might reveal interesting information hidden to the naked eye.
When implementing this feature I noticed that it did a quite good job at doing black & white conversions of photos.
Thinking about this it does actually make some sense, the first principal component
maximizes the variance of the values. So it should result in a wide tonal range in the resulting photograph.
This led me to develop a tool to explore this idea in more detail.
To give you a quick example let’s start with one of my own photographs:
While the composition with so much empty space is debatable,
I find this photo fairly good example of an image where a straight luminosity conversion fails.
This is because the really saturated colors in the sky look bright/intense even if the straight
up luminosity values do not suggest that.
Hover it to see the results of a straight luminosity conversion instead.
In this case the PCA conversion does (in my opinion) a better job at reflecting the tonality in the sky.
I’d strongly suggest that you experiment with the tool yourself.
If you want a bit more detail on how exactly the conversions work please have a look at the help page.
Do I think this is the best technique for black and white conversions? No.
You will always be able to get better results by manually tweaking the conversion
to fit your vision. Is it an interesting result? I’d say so.
I’ve just released version 1.0 of smartcrop.js.
mainly for generating good thumbnails.
The new version includes much better support for node.js by dropping the canvas dependency
as well as support for face detection by providing annotations.
The API has been cleaned up a little bit and is now using Promises.
Another little takeaway from this release is that I should set up CI even for my little
open source projects. I come to this conclusion after having created a
dependency mess using npm link locally which lead to everything working
fine on my machine but the published modules being broken. I’ve already set
up travis for smartcrop-gm,
More of my projects are likely to follow.