help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new to octave - need help with running user-defined function files


From: Theresa Bullard
Subject: Re: new to octave - need help with running user-defined function files
Date: Fri, 10 Mar 2006 19:27:09 -0800

Joe, thanks for all your help.

here are my responses after following up on your suggestions:

How do I set up or change my .bash_profile or .bashrc? Where would these files be located? I do not see them in the home directory. What would I change in these files?

You will not see your .bash_profile or .bashrc files in terminal because they are hidden unless you do ls –a to show all files.

I've tried the ls -a command and the only hidden bash file I see is .bash_history, no .bash_profile or .bashrc. Can I just create them? Would they be found somewhere other than my home directory?

The only essential lines in my .bash_profile (used by Terminal, as I recall) or .bashrc (used by xterm, as I recall) are
export GNUTERM=aqua
export DISPLAY=:0.0

These set the graphics display to AquaTerm. Change aqua to x11 if you are using X11. It shouldn’t matter which terminal you use because photo type images will open in as .bmp files in the Apple Preview application. To edit the .bash files, I suggest getting TextWrangler or Smultron (free downloads) if you don’t already have one of these. If you’re a UNIX person, you could use vi or emacs.
...
Do I need to do a batch compile of these functions to get them integrated into Octave? If so, how do I do that here?

If they are all .m scripts, you do not need to compile them.

yes, they are all .m scripts

You have several options regarding how to locate the image processing files for use. First, as you have discovered below, you can cd into the directory where the image processing files reside, copy your data to the same directory, and everything should work.

That's the first thing I tried. It was only after that did not work that I started moving my image data files around into the default IMAGEPATH directory. After figuring out other issues (see below) this now works ... almost...

Octave looks first in the local directory, and then (in your case) in /usr/local for the files to use. Second, you could install the image processing files in a directory in the same directory tree in /usr/local where the octave-forge routines are located. That’s how I have the digital signal processing library from Stearns and David installed.

Hmmm...
Currently my image processing files are in
/usr/local/share/octave/site/m/ComputerVision//
and there are several folders containing different .m scripts that are available

My octave forge routines are in
/usr/local/share/octave/2.1.71/site/m/octave-forge//
and there are several folders containing different .m scripts, where ~/image is the one needing to be accessed for the current routine

so, would I put all these folders under the octave-forge directory above? or under the ~/image directory?

Third, you could create a .octaverc file that adds the image processing directory to your octave load path, as you originally thought. I’m sure people on this list could help you do that.
I am able to use the built-in octave functions, although in attempting to use some of the image functions as a basic step before even trying the computer vision functions from Kovesi, I cannot seem to access the image files. I have cd’ed into the directory the image files are stored in, and they are recognized as being in IMAGEPATH, but then I get the following error trying to use imread

octave:2> file_in_path(IMAGEPATH, 'gray_image.jpg')
ans = /Users/tvb/usr/local/share/octave/2.1.71/imagelib/gray_image.jpg
octave:3> im1 = imread('gray_image.jpg')
error: could not read file: /var/tmp/oct-EHDvjn
error: evaluating if command near line 189, column 4
error: called from `imread' in file `/usr/local/share/octave/2.1.71/site/m/octave-forge/image/imread.m'
error: evaluating assignment expression near line 3, column 5
octave:3>

I’ve tried loadimage(‘gray_image.img’) also, but perhaps my file format is not right even though it seemed like it was what Octave was asking for based on the online manual. I have Graphical Converter, so I tried to convert from .jpg to .img and .ppm which seemed to be the file formats that Octave can work with. My preference would be to just use jpg’s and from seeing some of the other threads, it looks like this should be possible.   

This looks to me like an internal octave-forge error from (perhaps) reading a locally created scratch file. (The .jpg extension should be OK.) You can look at imread.m by copying it from /usr/local/ to an unprotected location like ~ after you find it (In Terminal: find . -name image.m –print). Anyone else got any ideas?

Here are the lines from imread that generated the error

fid= fopen(tnam,"rb");
#
# can we open the pipe?
# if not 1) The file format is wrong and the conver program has bailed out
# 2) The apropriate converter program hasn't been installed
#
if fid<0;
unlink(tnam);
error(['could not read file: ' tnam]);
end

I do know that octave relies on ImageMagick for some image input/output, but I don’t know how much of ImageMagick  is included with the HPC download.

Looks like ImageMagick was not included in the HPC download. I downloaded ImageMagick-6.2.6 from the official site but was unable to configure and compile it from source. So, I found an older version of it in binary format that works for OS X 10.3.9 (it is ImageMagick-6.1.7). This seems to have solved the error problem with imread.

Now the main problem I'm having is that the directory structure of the Image Processing Package is such that the .m files are distributed through many different directories/folders. I suppose that since I don't need to use all of these at this point I can just duplicate the ones I do call and put them all in the same flat directory. This works, but I'd think that it should also work fine with them in a multi-level directory structure also...afterall, it should be doing the recursive search for undefined functions right? '/usr/local/share/octave/site/m//' is part of my DEFAULT_LOADPATH, and these functions are currently all under that directory tree.

Second, after putting all the user-functions that I needed in the same directory and running the script everything seemed to work up until it called the octave function plot, which tried to call gnuplot and failed. I have loaded gnuplot on my computer, but either it is not in the right directory location, or because I haven't been able to set the variables in the .bash_profile and .bashrc files as you suggested it is not able to access it. Or something else...?

So, progress has definitely been made thanks to your input. I am certainly learning a lot of new stuff here, which is great. Any further suggestions based on these new questions?

Thanks so much,
Theresa


reply via email to

[Prev in Thread] Current Thread [Next in Thread]