eror: rgb2gray undefined in Octave 4.2.2

可紊 提交于 2019-12-02 17:35:37

问题


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:


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.



来源:https://stackoverflow.com/questions/51358082/eror-rgb2gray-undefined-in-octave-4-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!