Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Octave: 'rgb2gray' undefined error

Tags:

octave

Please advise what to do to make the rgb2gray work in Octave. I found this thread, but still I would like to use the rgb2gray functionality instead of manually calculating for each color channel.

The code that I run:

I = imread('smile.jpg');
G = rgb2gray(I);


The error I get:

error: 'rgb2gray' is undefined near line 10 column6


Additional:
Octave version: 3.6.4
Image package is installed. Version: 2.0.0.
The 'rgb2gray.m' is installed in C:\Octave\share\octave\packages\image-2.0.0

Thanks,

like image 902
vbnk Avatar asked Dec 16 '22 02:12

vbnk


1 Answers

The problem is that you didn't load your packages. When you type pkg list you can find which ones are loaded by an asterisk in front of their names. Load a package with pkg load image.

Having to load a packages is that thing that most users find strange but if you compare with other languages, such as Python, Perl, or C++, would you expect them to import, use, or #include every libraries available in the system by default? See Octave's FAQ for more details.

like image 80
carandraug Avatar answered Jan 22 '23 00:01

carandraug