Matlab under Ubuntu

June 27, 2008 10:17 pm | In Tech | 1 Comment | hide

Some tips:

  • Q: Matlab desktop does not show up correctly.
    A: export MATLAB_JAVA=/usr/lib/jvm/java-6-sun/jre/ (requires Sun Java 6 Runtime)
  • Q: Matlab windows disappear in taskbar (Window List applet).
    A: export AWT_TOOLKIT=MToolkit
  • Q: Printing in Matlab throws java exception.
    A: Go set all printers > Job Options > Orientation to something other than “Automatic Rotation”.

Links: 1, 2.

Tags: , ,

Ubuntu: upgrade to 8.04

April 26, 2008 1:00 am | In Tech | No Comments | hide

Simply do: do-release-upgrade. Initially Mr. Ubuntu said “A unresolvable problem occurred while calculating the upgrade”. /var/log/dist-upgrade/main.log complained ubuntu-desktop package was f**ked up. After manually removing this package, everything went smoothly. Took about 6 hours.

Tags: , ,

Microsoft Visio save as EPS

February 8, 2008 2:04 pm | In Tech | 2 Comments | hide

To convert a Microsoft Visio document to EPS without losing scalable vector format (and without installing 3rd-party software…):

  1. Install Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs (only available for Office 2007?).
  2. Save Visio document as PDF in Visio 2007.
  3. Convert PDF to Postscript (.ps) with pdf2ps utility.
  4. Open .ps file with gsview, and select File -> PS to EPS, be sure to check “Automatically calculate Bounding Box”.

Now you have an EPS file to be embedded into your LaTeX document. Many other converting methods exist, see also Visio and EPS.

Tags: , , , ,

TeraStation does not auto-mount USB disk

January 31, 2008 4:32 pm | In Tech | No Comments | hide

Don’t know exactly why TeraStation does not automatically mount my external USB disk, but the fix is to manually fill in the USB disk GUID in /etc/melco/diskinfo. GUID can be obtained from /proc/scsi/usb-storage/*. Related script is possibly /etc/hotplug.d/scsi_device/usb-buffalo.hotplug.

Tags: ,

Convert WordPress database from Latin1 to UTF-8

January 12, 2008 5:39 pm | In Tech | 2 Comments | hide

Some early WordPress databases use raw Latin1 encoding to represent UTF-8 characters. The following seems to be an O.K. way to convert those databases to native UTF-8 databases (at least it works for me, Mysql 5.0.45):

  1. Stop/restrict web service.
  2. Dump the database:
    $ mysqldump --default-character-set=latin1 --databases wordpress > m.sql
  3. Change encoding settings in m.sql, including table default encoding and client communication encoding:
    $ replace "CHARSET=latin1" "CHARSET=utf8" \
        "SET NAMES latin1" "SET NAMES utf8" < m.sql > m2.sql
  4. Import the “converted” sql:
    $ mysql < m2.sql
  5. Add the following lines to WordPress wp-config.php
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
  6. Reopen web service. That’s it.

Note: For future convenience, you might as well change the database default encoding to utf8.

Ref to WordPress documentation for details: here and here.

Tags: , , , ,

Defective Pixels in Canon A570 IS

November 25, 2007 6:12 pm | In Tech | 8 Comments | hide

We know almost every pixel array (CCD sensor in camera, LCD screen, etc) has defective pixels. For camera CCD sensor, a few defective pixels can ruin good pictures, but we usually don’t see those pixels in the JPEG picture. Here’s a short story about those defective pixels.

I installed CHDK on my Canon A570 IS camera and shot a few test pictures to find out defective pixels of my camera. To my surprise, this 7.1 mega-pixel CCD sensor has couple thousands defective pixels. The following picture represents the raw output from CCD sensor when I shot a 15 sec picture with ridiculously bright light source: (The green border is just showing image boundary, not from the actual picture.)

0486.png

The raw file is 3152 columns by 2340 rows, 10 bits per pixel, so the file size is 3152 x 2340 x 10 bits = 9219600 bytes. The first few columns and rows are used for background subtraction (masked pixels, their values are usually around 30-40 on this 210 = 1024 scale), so the active area is actually 3072 x 2304 pixels. The above picture is RAW CCD output down scaled to 0-255 and converted to 8-bit gray PNG (i.e., before demosaicing/gamma correction/any other process taken place). As you can see, there’re a lot (9205) of 0-valued defective pixels in the active area. There is no defective pixel in the masked area.

When I shot with faster shutter speed, I have less (2991) defective pixels. The following was shot with 1/250 sec shutter speed, showing CCD value 0 as black (defective pixels), 1-40 as gray (masked pixels), and 40-267 as white. No pixel has value more than 267.

0488.png

I shot a lot of RAW pictures and found the number of defective pixels is either 9205 or 2991. Generally speaking, the slower the shutter speed, the more chance I get 9205 defective pixels. But I did have 2991 defective pixels with 1/30 sec picture, and 9205 defective pixels with 1/250 sec picture, with all other settings the same. So I have no idea what determines the defective pixel pattern. Also what’s interesting is those 2991 defective pixels are subset of the 9205 defective pixels.

If I go ahead and demosaic, combining RGB channels together, This is part of the image I get: (You can see defective pixels in different color channels.)

0405-with-bad-pixel-small.png

Instead, most RAW format processors find those 0-valued (sub)pixels and interpolate over with neighbor pixels. By doing that, here’s what I get: (white balance etc. was tuned a little bit as well)

0405-without-bad-pixel-small.png

Nicely white, no annoying dots any more, right? This “cheating” process is done inside the camera when saving JPEG file, and also done in most RAW format conversion. DNG specification states that:

Defective pixels should be mapped out (interpolated over) before the raw data is stored as DNG.

Enjoy your camera with 0.1% defective pixels!

Tags: , , , , , , ,

Canon A570 IS 1.01A firmware dumped

November 11, 2007 1:20 am | In Tech | 2 Comments | hide

Today I dumped Canon PowerShot A570 IS 1.01A firmware using tricks from CHDK website. Here’s a little bit tech detail for my own record.

  • Receiver: Thorlabs DET110 + 10k terminating resistor.
  • Recording: 48 kHz sampling, 8 Bit, Mono. Delay settings I used:
    #define DELAY_SYNC   200
    #define DELAY_SPACE  50
    #define DELAY0       50
    #define DELAY1       100

    I slowed down the blinking to make my sound card happy. However, the following faster setting:

    #define DELAY_SYNC   45
    #define DELAY_SPACE  50
    #define DELAY0       1
    #define DELAY1       25

    does give very clean waveform (even with the shortest 5 us pulse) on the scope, so it should work with good sampling device (say a better sound card).

  • LED: I used the least-frequently-used blue LED
    #define LED_BLUE 0xc02200c4
  • Recording level set at about -5dB to -3dB
  • Decoder setting:
    #define LEVEL_THRES_HI  0xa0
    #define LEVEL_THRES_LO  0x80
    
    #define LEN_SYNC        10
    #define LEN_SPACE       1
    #define LEN_0           3
    #define LEN_1           6
  • Total dump time is about 2.5 hours. (about 3700 bits per second)
  • I did not have any CRC error! I added an md5 checksum at the end. The camera took about 17 seconds to calculate md5sum of the 4MB firmware. Of course, no surprise, md5sum matches.
  • Starting part of the dump:
    dump start
    Decoded as 00110000, 00110001, 00110010, in other words, ASCII ‘0′, ‘1′, ‘2′. Also, for some reason the waveform is inverted (compared with CHDK website), so I have to manually invert the waveform for adc.
  • The camera freezes about 3 milliseconds every few seconds. Here’s typical behavior:
    dump delay
    Since the protocol is decently robust, this extra delay is not a problem at all.
  • Dumper code available for download: a570is dumper (based on code from CHDK website and kxn’s modification.).

Brilliant kxn ported CHDK to A570 IS 1.01A within two days.

Tags: , , , , ,

WordPress 2.3 native tagging support

October 1, 2007 9:52 am | In Tech | 4 Comments | hide

Why tagging if you already have category system? I like to think the blog as a book: categories are like the table of contents, while tags are the keyword index in the appendix. These two are complementary and you obviously use both of them. Vendor catalogs and academic journals often have similar two systems as well.

If your WordPress theme does not support native tagging, here are two templates to save you:

  • Show tags after blog entry. Insert the following at an appropriate location (reference)
    <?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
  • Show tag cloud. Add the following in the sidebar (reference)
    <?php wp_tag_cloud(''); ?>

Tags: , ,

下一页 »

This weblog is licensed under a Creative Commons License.
Powered by WordPress. Theme based on Pool by Borja Fernandez.