Use MATLAB to prompt user to select a image file -
i trying implement function starting prompting user select image , image operation. here code:
[filename, path] = uigetfile ('*.bmp; *.png; *.jpg','select secret image'); secretimg = filename; r = secretimg(:,:,1); g = secretimg(:,:,2); b = secretimg(:,:,3);
however, prompt me error:
index exceeds matrix dimensions.
error in main (line 16) g = secretimg(:,:,2);
it works traditional method specify filename inside code this:
%secretimg = imread('images/lena.bmp');
try this:
secretimg = imread(strcat(path,filename));
full code:
[filename, path] = uigetfile ('*.bmp; *.png; *.jpg','select secret image'); secretimg = imread(strcat(path,filename)); %// 1 alternative use `fullfile` rayryeng suggested, %// secretimg = imread(fullfile(path,filename)); r = secretimg(:,:,1); g = secretimg(:,:,2); b = secretimg(:,:,3);
Comments
Post a Comment