0

rgb2hsv function gives error for some images, but gives good result for some other, in the code shown below.

    [fname path] = uigetfile('*.*','open image file');%*.*
    %dn=path;
    [path,name,ext,ver] = fileparts(fname);
    handles.fname = strcat(name,ext);
    [handles.queryx, handles.querymap] = imread(fname);
    figure
    imshow(handles.queryx, handles.querymap); %This displays the image.
    question_Callback(hObject, eventdata, handles)
    % Obtain HSV format of the image...
    handles.queryhsv = rgb2hsv(handles.querymap);
    guidata(hObject,handles)

if i run this for stone sculpture images results in error

    ??? Attempted to access r(:,2); index out of bounds because size(r)=[0,0,1].

    Error in ==> rgb2hsv at 74
         g = r(:,2); b = r(:,3); r = r(:,1);

    Error in ==> CBIR_MJP>insert_Callback at 101
    handles.queryhsv = rgb2hsv(handles.querymap);

    Error in ==> gui_mainfcn at 96
         feval(varargin{:});

    Error in ==> CBIR_MJP at 42
         gui_mainfcn(gui_State, varargin{:});

    Error in ==>
   @(hObject,eventdata)CBIR_MJP('insert_Callback',hObject,eventdata,guidata(hObject))


     ??? Error while evaluating uicontrol Callback

Y IS IT SO?

Chethan
  • 213
  • 3
  • 7
  • 19
  • I think the argument you are passing to `rgb2hsv` is sometimes empty. Because it says that `size(r)=[0,0,1]`. Use debugger and go line by line in your program. – Autonomous Mar 16 '13 at 18:09
  • I just checked the `rgb2hsv` code and it appears to me that you are passing a 2-D image, so not an RGB image. Also instead of passing the `map` you got from `imread`, you should pass `handles.queryx`. – Autonomous Mar 16 '13 at 18:23
  • However I'm getting result for same code but for different image (flower) – Chethan Mar 16 '13 at 18:41
  • In the flower image, colormap (`handles.querymap` in your case) must not be empty (check using debugger). But you can send the image directly instead of a colormap. – Autonomous Mar 16 '13 at 18:49
  • 1
    Well after a deep study on rgb2hsv, i got to know that it depends on BIT DEPTH of an image. since my images are of 16 bit i was getting error like out of bound. Anyhow thank you for your help. – Chethan Mar 18 '13 at 17:18

0 Answers0