how can i use image which is save in variable?

in the following code i wanted to use gray image which saved in variable b for further use,but it gives an error "undefined b" on second line... kindly sort this out
CODE:
i=imread('C:\Users\Romesha\Desktop\eye.jpg');
b=rgb2gray(i);
imshow(b);
im = imread(b);
imshow(im);

4 comentarios

Azzi Abdelmalek
Azzi Abdelmalek el 21 de En. de 2014
Post the entire error message
im = imread(b);
is not going to work. imread should be called on a file, not a variable, like you did in
i=imread('C:\Users\Romesha\Desktop\eye.jpg');
Good catch, Bruno. I got sidetracked by the "undefined b".
But to be more correct, you can use a variable in imread(), but it needs to be a variable that contains a string. For example,
F = 'C:\Users\Romesha\Desktop\eye.jpg';
im = imread(F);
romasha
romasha el 22 de En. de 2014
this is the entire error message
  • * *Error in @(hObject,eventdata)gui('PB2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback* * *
and respected sir i know the above answers already and i want to use that image which is store in variable b so how can i give the path of that image "im=imread(i want gray image which save in variable b in this paranthesis)"

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 21 de En. de 2014

Comentada:

el 22 de En. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by