Friday, January 25, 2013

Sharpening Moon with deconvolution

I bought a Barlow 2x lens for my Skyliner 200 and immediately went out to test it. I actually got quite lucky to have a clear sky that night. I took some photos of Jupiter and Moon and shared them on IRC. A friend suggested I should sharpen the photo of Moon with something like this:

Having studied physics, I'm familiar with the concept of convolution and I'm aware it should be possible in theory to reverse the process. Still the images on that page seems like magic to me. The software Astra Image seems like a nice program but of course it has a price. I'm not against commercial software and the price isn't too high, but I always try to look for an open source alternative to everything.

I found Grey's Magic Image Converter. It even has a plugin for Gimp. Better yet, it installs right from Portage on Gentoo. There are .debs on their page so probably installation is easy also on Debian based distros such as Ubuntu.

I didn't try the command line version yet, only the Gimp plugin. Some page I found (and lost again so no link) suggested on command line you get better results than plugin. Perhaps there are more parameters to set or something. I'll try that later, but now the Gimp plugin.

I took some photos of the Moon. With my new barlow, I can fit about one fourth of the Moon in one picture. I made a panorama of six photos with Hugin. Because of my haste to get something ready, the images were jpegs from the camera. That's why the dark grey circle around the Moon. I probably should do some editing for the raw photos before stitching the panorama.

The photo is huge. Here's a part of it:

And here is the same photo deconvoluted:

See the difference? I applied (in haste as usually) G'MICs deconvolution filter with almost the default settings and that's what I got. Btw it took quite a while for 4200x4300 image.

Here are the original and deconvoluted photos:

Left one is the original and right one deconvoluted.
EDIT: Looks like Google doesn't show the photos in their original size. I'll add them elsewhere and link here.

Sunday, January 6, 2013

Script to control Canon 1100D on Raspberry Pi

I've finished the first part of my plan to use Raspberry Pi to remote control a camera. I put together the efforts from and and wrote a Python script to do it all.

Why? With the camera itself I can take max 10 photos sequentially after having to go to the camera and press the trigger again, I can use exposure times only to max 30 seconds and as a result I get hundreds of photos named IMG_6013.CR2 and such.

The script I wrote:
  1. Asks for 
    • ISO
    • exposure time
    • number of photos
    • name for the object in photos.
    Name is required for naming the pictures and directory for them.
  2. Sets all the necessary settings for camera. You need of course to aim the camera, focus it manually and set the control wheel to manual mode (M).
  3. Takes number of photos, resetting the USB connection after each photo (because on RasPi this is required)
  4. Downloads each photo instantly from the camera and uploads it to my NAS (mounted by NFS on RasPi). The photos are put to a directory by name asked before and named with a timestamp. For example M42_2012-12-16_16.22.28.099570.cr2.
I just ran a test of 200 photos with exposure time of 31 seconds and it seems to have worked perfectly.

The script and instructions for it can be seen here. It's easier to share files on Google Sites than Blogger and I also want a permanent page of that. I'll update the page to always include the newest version of my script.

Tuesday, January 1, 2013

Mosh - Mobile Shell and unavailable ports

The idea of Mosh is awesome. An SSH-connection that does not disconnect even if network does. On a mobile environment and behind unstable connections an extremely nice feature. After setting it up on our IRC shell server I've been testing it with my Galaxy Tab. I found Mosh for Irssi Connectbot and I've been using it for a while now.


The server I referred to is almost on our control. It's a virtual server and we have a domain and lots of open ports. No own IP address though. That we have to share with couple other servers. That's why we don't have access to the ports necessary for Mosh. Mosh works by taking a normal SSH-connection and starting a mosh-server on user space. It chooses an open port from 60000–61000. Too bad we don't have access for those.

Solution 1

You can choose the port outside the default range. It's easy. Just connect with
$ mosh -p <port> <user>@<host>
I really don't see this as an option. Our server has at the moment about 20 users. Some more technically oriented than others. To connect, one has to know the available port range (which is 41000-41999 something...) and available port at the moment, since there are 20 other users. Maybe we could give everyone two or three ports for their personal use...

No. This is not an option.

Solution 2

Since the default port range is hardcoded in the source and there is no config file, I thought I'd change the code. In version 1.2.3, in file mosh-1.2.3/src/network/network.h there are lines
static const int PORT_RANGE_LOW  = 60001;
static const int PORT_RANGE_HIGH = 60999;
Change those to preferred ones, make, make install and things should work.

I didn't get into testing this before I found myself once again bothering the developers on IRC. This seems to be an efficient method of solving problems with open source. I only hope the developers don't mind...

Better solution

I had to compile this from source after all, but without any changes. In the Git version they have a feature of giving a port range as an argument to mosh-server. Mosh-server is the program mosh runs on server side after an successful SSH-connection and mosh-client then connects to mosh-server. They both have to know which port to use.

I installed mosh on /usr/local and renamed /usr/local/bin/mosh-server to /usr/local/bin/mosh-server.real. Then I created a new /usr/local/bin/mosh-server

/usr/local/bin/mosh-server.real $@ -p 44800:44999

Mosh calls for mosh-server, which again calls for mosh-server.real passing the original arguments and adding its own port range.

Users don't have to know any of this. They can now connect with
$ mosh <user>@<host>
and everything works as it should.

Best solution (to my opinion)

...would be a server side config file to define the default ports. Too bad there is no such file at the moment.