|Table of contents|
Downloading the image package
You will need to be able to load images for the third question in the assignment. In order to do this you will need to install a package in Octave. I have been dreading this for a while because the steps will be slightly different for everyone and I can guarantee that it will not work on every computer the first time.
Step 1: Download the file image-1.0.6.tar.gz onto your account/computer. This is located at Octave Forge (http://octave.sourceforge.net/) in the Packages section (http://octave.sourceforge.net/packages.html). If you cannot download it from there (some are complaining of only finding a link to something that ends in .tar.tar) try this link and rename (http://garsia.math.yorku.ca/~image106targz) after you download it.
Step 2: You will need to download two programs. One is "gcc" and the other is "Image Magick". If anyone can provide help on how to do this on Windows please do. I am hoping for a chance to work on a windows system soon so that I can fill in a few details on how to do this.
Step 3: Put the file in some directory where Octave will find it. If you are on a Windows, place it in the root of the C: drive and then when you are in Octave you can type cd C:\
Step 4: In Octave type the following line: pkg install image-1.0.6.tar.gz
Note that if you get an error in step 2 you will need to tell it the full path name of where the image-1.0.6.tar.gz file is located.
Step 5: Each time you load Octave type the following line: pkg load image
Running Octave remotely
The packages will only work in versions of Octave (probably) higher than 2.9. This means that if you have been running Octave off of titan (which runs 2.1.50someodd) then you will need to switch to a computer that runs a higher version. I will be getting you accounts on another machine if you want to run this remotely.
So working with images on a remote computer is slightly difficult, but it is worth learning a few commands and it isn't so bad:
So if you have an account on machinename.math.yorku.ca, then execute the command
and this will log you into a remote machine. You should be able to run octave on that machine. Also open a second window and type
This program called 'sftp' stands for secure file transfer protocol. The two commands you will need are put filename and get filename which will transfer a file to and from (respectively) the remote computer. Then you can use programs on the local machine that you are working on to display images.
For those of you who are running Octave remotely I can get you a special account. I have 10 of them for tonight and I will get more if it is necessary.
Example with imread and imwrite
Unless you install the package, Octave is only capable of saving files in 3 formats (and only two formats if it is a color image). Only one of those file formats can be used to view the image with other programs. Once you install the image package then you will have two new commands that we will need for the assignments. imread( filename) and imwrite( filename, R, G, B) or imwrite(filename, image).
Lets do a couple examples. Save an image off of the web for fun that is in jpeg format. Say it is called webimage.jpg. Remember to load the image package ( that is, run the command pkg load image at the octave prompt)
A = imread("webimage.jpg") (On mine, it only worked with single quotes eg. ' webimage.jpg' - Jen)
If Octave were designed well then the following command will work (if you are not running this remotely):
On my computer I had to rescale it after I converted it to a matrix of double values.
Note that if you do not convert to double before you divide by 255 then your images will round off to either 0 or 1 for each color channel and you get an image which has at most 8 colors in it.
One more item of interest
I haven't had the chance to experiment yet but we will do more with dominant colors in an image and there is a website called whatsitscolor.com.