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: Joe Koski
Subject: Re: new to octave - need help with running user-defined function files
Date: Fri, 10 Mar 2006 23:12:33 -0700
User-agent: Microsoft-Entourage/11.2.1.051004




on 3/10/06 8:27 PM, Theresa Bullard at address@hidden wrote:
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?

They are only recognized in your home directory. Yes, you can create them with any text editor. I usually create a file called new.bash_profile in the home directory (so I can see it and test it) and then cp it to .bash_profile later after I’m sure it works properly. To test a file you can “source new.bash_profile” in the home directory. Just be very careful when you are working with paths.

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?

No, no compilation is necessary. Most octave files are text scripts or data which are basic text files that can be easily edited with any separate editor. Watch text line endings though, octave recognizes only UNIX line endings, not Mac line endings. Most Mac editors will let you specify which line ending to use. It’s very confusing when you have he wrong line endings. Nothing seems to work. When you’re ready to run an octave script, save the script changes in the editor window, click on the octave Terminal window, and type the name of the script. You can up-arrow if you have already run the script before.





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?

In theory, you could split them as long as they can be seen by octave. In octave, type help, and see if all the files that you need are visible to octave. You can type “more off” to keep from paging through the list. If part of them are not visible, then try constructing the paths in .octaverc so that they can be found.

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.

Good. I got my ImageMagick-6.2.6 working today by rebuilding it on OS X 10.3.9. It’s not easy. You must cp some JPEG header files (from a separate build) into /usr/local/include before you build ImageMagick and octave-forge. If your ImageMagick works, don’t change anything. You may have the same version of ImageMagick that Guarav Khanna at HPC had when he built HPC octave. Incidentally, if you have Mac build questions, Guarav often has the answers on his site, or by e-mail.

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.

This is mostly your choice, based on your particular experience. The key in your case may be setting up a .octaverc file to control the paths in your home directory.

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...?

The final fix is to put the export GNUTERM lines in .bash_profile, but you can try doing “gset term aqua” in octave to see if that helps get a plot.

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?

Like you, I’m a relatively new octave user (2+ years). You are already on the verge of knowing far more about the image functions than I do.

Octave is good at telling you what happened when it quit. The best teacher is trial and error. The octave routines size and length (without semi-colons) are often your friends when you’re trying to figure out why things don’t work.

Good luck.

Joe


Thanks so much,
Theresa




reply via email to

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