From: Paul on 31 Mar 2010 09:59 For the last 3 hours ive been unable to fix what should be easy. I want to use a user defined variable to save the file to. where have i gone wrong. thanks. relevant Code: flashImage = double(imread(test.jpg))/255; name = inputdlg('enter a name for your image','',1,{'PictureName'}); name imwrite(flashImage, name,'jpg'); Output: name = 'PictureName.jpg' ??? Error using ==> imwrite at 363 Invalid colormap Error in ==> GUI>importPictures_Callback at 355 imwrite(flashImage, name,'jpg'); Error in ==> gui_mainfcn at 96 feval(varargin{:}); Error in ==> GUI at 42 gui_mainfcn(gui_State, varargin{:}); ??? Error while evaluating uicontrol Callback >> Changing to : imwrite(flashImage, HSV,name,'jpg'); gives : Invalid input arguments: missing filename
From: Steven Lord on 31 Mar 2010 10:20 "Paul " <overclocked89(a)hotmail.co.uk> wrote in message news:hovkf9$d1v$1(a)fred.mathworks.com... > For the last 3 hours ive been unable to fix what should be easy. > > I want to use a user defined variable to save the file to. > > where have i gone wrong. > thanks. > > relevant Code: > > flashImage = double(imread(test.jpg))/255; > name = inputdlg('enter a name for your image','',1,{'PictureName'}); > name > imwrite(flashImage, name,'jpg'); > > > > Output: > > name = > 'PictureName.jpg' From the way that's displayed, I'm guessing it's a 1-by-1 cell array whose only cell contains the string PictureName.jpg. If so, extract the contents and pass them into your IMWRITE call: imwrite(flaseImage, name{1}, 'jpg') -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Paul on 31 Mar 2010 10:45 thanks, but now ive got: ??? Error using ==> writejpg at 43 3-D indexed image data not supported for JPEG files Error in ==> GUI>importPictures_Callback at 355 imwrite(flashImage, HSV,name{1},'jpg');
From: Paul on 31 Mar 2010 10:47 forget that, Removed the colormap from the write function, and works great. thanks for spotting my mistake :)
|
Pages: 1 Prev: Stop windows sleeping while matlab running Next: Text from excel to matlab |