1

I am loading an image in MATLAB and trying to resize it to certain size. This is my code:

img = imread(strcat(train_path,'/','aa.jpg' ));
[w h d] = size(img);
fprintf('%s %d %d %d \n', strcat(train_path,'/','aa.jpg' ), w, h ,d );

%image(img)
resize_img = imresize(img, [96,96]);

All works well except the imresize function. The error is imresize undefined.

chappjc
  • 30,359
  • 6
  • 75
  • 132
user824624
  • 7,077
  • 27
  • 106
  • 183
  • If you can't get `imresize`, consider rolling your own with `interp2`. See [this example](http://stackoverflow.com/a/20009314/2778484) for a starting point. – chappjc Apr 09 '14 at 17:29

2 Answers2

3

You need to have the image processing toolbox for imresize, but not for imread, which is included in Matlab by default.
http://www.mathworks.com/products/image/

honi
  • 946
  • 1
  • 7
  • 18
  • how do I load image processing toolbox in my script ? – user824624 Apr 09 '14 at 16:29
  • is it installed? type `ver` to see your installed toolboxes – honi Apr 09 '14 at 16:32
  • I used ver, found no packages installed, I am using on octave, I will try to download and install – user824624 Apr 09 '14 at 16:37
  • Hi,honi, I have downloaded one from http://sourceforge.net/projects/octave/files/Octave%20Forge%20Packages/R2009-06-07/, image-1.0.10.tar.gz, is it ? as I downloaded it, how should i install with octave – user824624 Apr 09 '14 at 16:41
  • Hi, honi, I tried the command in octave, but with warming, warning: file -forge does not exist warning: file image does not exist – user824624 Apr 09 '14 at 16:44
  • in octave, cd to the directory where you have the download and then try `pkg install image-1.0.10.tar.gz` – honi Apr 09 '14 at 16:49
  • alternatively, you can try updating octave to the newest version and then trying the `pkg install -forge image` command again – honi Apr 09 '14 at 16:51
  • I follow this, http://www.gnu.org/software/octave/doc/interpreter/Installing-and-Removing-Packages.html, replace image-1.0.0.tar.gz with image-1.0.10.tar.gz, no work. so should I download the package firstly, put into a installation folder and then use the command ? – user824624 Apr 09 '14 at 16:52
  • does `pwd` in octave give the same folder where the file is stored? if not, cd to the correct folder – honi Apr 09 '14 at 16:54
  • HI, honi, I cd to the folder in octave where the package is, tried the pkg install command, it worked in half that a error popped up, saying error: called from `pkg>configure_make' in file /usr/share/octave/3.2.4/m/pkg/pkg.m near line 1253, column 2. perhaps I would reinstall octave in latest version – user824624 Apr 09 '14 at 19:12
  • what is the entire error? do you have make installed? what does `which make` do if you type it in at the command line? what system are you on? – honi Apr 09 '14 at 19:22
  • on ubuntu 12.04, make is installed with version 3.81, octave version is 3.2.4. the entire error is make: mkoctfile: Command not found make: *** [__spatial_filtering__.oct] Error 127 'make' returned the following error: make: Entering directory `/tmp/oct-nbDhlk/image-1.0.10/src' mkoctfile __spatial_filtering__.cc make: Leaving directory `/tmp/oct-nbDhlk/image-1.0.10/src' error: called from `pkg>configure_make' in file /usr/share/octave/3.2.4/m/pkg/pkg.m near line 1253, column 2 error: called from: error: /usr/share/octave/3.2.4/m/pkg/pkg.m at line 714, column 5 – user824624 Apr 09 '14 at 19:30
  • in my command line, make is installed, but in octave, if type 'make -v', then says 'error: `make' undefined' – user824624 Apr 09 '14 at 19:31
  • everyone seems to think that you should try installing using apt-get: `sudo apt-get install octave-image` http://octave.1599824.n4.nabble.com/Ubuntu-12-04-quot-pkg-install-quot-does-not-work-td4657080.html – honi Apr 09 '14 at 19:36
  • I think that is right , a big hug to u, honi. one more question, if I want to install other packages, just apt-get install octave-package-name, is it ? – user824624 Apr 09 '14 at 19:45
  • thats what it seems. i dont use octave that often so im not 100% – honi Apr 09 '14 at 20:38
2

In octave you need to load image processing package at the beginning of your code

pkg load image
img = imread(strcat(train_path,'/','aa.jpg' ));
...

it adds the image package to the path.

sali
  • 219
  • 4
  • 10