0
votes

I am new to Octave platform and am trying the image tool for image processing version-2.8.0. I have installed this tool using 'pkg install -forge image'. It installed perfectly and even contains in the package list. Now when i try to convert a colored image into gray scale it gives me following error.

warning: the 'rgb2gray' function belongs to the image package from Octave Forge but has not yet been implemented.
Please read http://www.octave.org/missing.html to learn how you can contribute missing functionality.
error: 'rgb2gray' undefined near line 1 column 1*

Here is my code:

    pkg load image;
    img = imread('IMG_20170815_004922_213.jpg');
    img_gray = rgb2gray(img);
    imshow(img_gray);

I have read some errors that were due to not having 'pkg load image' line that is like an import statement. But in my case even this statement haven't solved my problem. I am using Octave Version-4.2.2 , Windows 7 64-bit and i5-processor.

1
It says it doesnt exist. Have you considered it may not exist? - Ander Biguri
rgb2gray should be included in image-2.8.0. Can you check, that you have ".../image-2.8.0/rgb2gray.m" in your installation? Do you see some warnings on startup like "blabla shadows blabla?" - Andy
works for me. Are you sure you are using Octave 4.2? Reinstall the image package. - carandraug
@AnderBiguri I have used ' pkg list' command and it includes image tool. Even in the image tool it consists of 'rgb2gray' in type conversion of image package. - Vishwas Mehra
also, as carandraug has pointed out in his answer, octave 4.4.0 is now out, which offers that function out-of-the box without the need to load the image package. you might want to consider upgrading your octave to the latest version - Tasos Papastylianou

1 Answers

1
votes

The image package decides at install time whether it should install the rgb2gray function or not. Octave 4.4 includes an implementation of rgb2gray so the image package at install time does the following:

  1. start Octave in another process (octave -qf)
  2. check if the rgb2gray exists in this new process
  3. adds rgb2gray to list of functions to install, only if function is missing

This means that if starting a new Octave process when you installed the package had such a symbol, then you might end up with the image package without the function. I'm not sure how that could happen since the check is done after starting octave without reading any initialization file.

One possibility is if you have some hack in Octave to automatically load the image package and that installation of the image package you done was an upgrade.

Solution: uninstall and then install the image package.