Jonathan Thomson's web journal

Enable Octave to Read 16 bit Images August 22, 2010

Filed under: Uncategorized — jethomson @ 4:05 am

This how to is a set of instructions for rebuilding libgraphicsmagick so it can process 16 bit images and rebuilding octave so it can take advantage of the new graphicsmagick libraries. This document assumes you’ve already installed octave using a package manager so that all of it’d dependencies have been resolved. Read over the entire how to before executing it. I do _not_ recommend you copy and paste it as a shell script and run it. Pay attention to each step and examine each command before hitting enter; I may have made a few typos.

su -c "apt-get install build-essential fakeroot"
su -c "apt-get build-dep libgraphicsmagick++3"

mkdir -p ~/src_tmp/{gm,oct}/src_pkgs
cd ~/src_tmp/gm/src_pkgs
apt-get source libgraphicsmagick++3
mv ~/src_tmp/gm/src_pkgs/graphicsmagick-1.3.12 ~/src_tmp/gm
cd ~/src_tmp/gm

#copy the following text into a file named rules.patch and save in ~/src_tmp/gm
--- graphicsmagick-1.3.12/debian/rules  2010-08-22 00:36:45.000000000 +0000
+++ debian/rules        2010-08-22 00:42:03.000000000 +0000
@@ -64,6 +64,7 @@
 
        CFLAGS="$(CFLAGS)" CXXFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
            ./configure $(gm_confflags) \
+               --with-quantum-depth=16 \
                --enable-shared \
                --enable-static \
                --enable-libtool-verbose \
#end copy
patch -p0 < rules.patch
cd ~/src_tmp/gm/graphicsmagick-1.3.12
debuild -i -us -uc -b
cd ~/src_tmp/gm

# install packages that resulted from debuild: 
# libgraphicsmagick++3 and libgraphicsmagick3 are required to run the octave binary
su -c "dpkg --install libgraphicsmagick++3_1.3.12-1_i386.deb libgraphicsmagick3_1.3.12-1_i386.deb"

# libgraphicsmagick++1-dev and libgraphicsmagick1-dev are needed to build octave from source
su -c "dpkg --install libgraphicsmagick++1-dev_1.3.12-1_i386.deb libgraphicsmagick1-dev_1.3.12-1_i386.deb"

# now start rebuilding octave from source
cd ~/src_tmp/oct/src_pkgs
apt-get source octave3.2
mv ~/src_tmp/oct/src_pkgs/octave3.2-3.2.4 ~/src_tmp/oct
cd ~/src_tmp/oct/octave3.2-3.2.4
debuild -i -us -uc -b
cd ~/src_tmp/oct
# install packages that resulted from debuild: octave3.2 and octave3.2-common
su -c "dpkg --install octave3.2_3.2.4-6_i386.deb octave3.2-common_3.2.4-6_all.deb"\
Advertisements
 

2 Responses to “Enable Octave to Read 16 bit Images”

  1. Daniel Canelhas Says:

    Thank you very much Jonathan.

    I tried this in ubuntu 11.10 and it worked fine (with some modifications)
    the patch step didn’t work so I manually edited the file called “rules” (in ~/src_tmp/gm/graphicsmagick-1.3.12/debian) by adding “–with-quantum-depth=16 \” after the line that says “–enable-libtool-verbose \” in that file.

    debuild isn’t installed by default in ubuntu so
    sudo apt-get install devscripts

    to build octave you will also need to do:
    sudo apt-get install libcurl4-gnutls-dev libftgl-dev

    (and maybe some others that I might already have added manually)

    If you are using ROS-electric (robot operating system) this will cause a conflict and ROS will be uninstalled. This is fine, you can reinstall ROS after compiling and installing octave from the resulting debs (since only the building requires the conflicting package, not octave itself).

    after that you can prototype algorithms dealing with images where pixels have some physical meaning (like temperature or distance)

    example: depth-image d1.png

    octave:1> Im=imread(‘d1.png’);
    octave:2> whos
    Variables in the current scope:

    Attr Name Size Bytes Class
    ==== ==== ==== ===== =====
    Im 480×640 614400 uint16
    ans 1×30 30 char

    Total is 307230 elements using 614430 bytes


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s