From: Dave on 2 Jul 2010 05:31 Hi, Here I am saving each image every time when loops goes by 1 using an image counter 'imagecount', my intention is to save image when the count is even. I tried using imwrite() as the code I supplied here, but matlab popped up an error,I have given it. Code I tried: imcount = num2str(imagecount); fid=fopen('C:\ipfilteredset','w'); name = strcat('\ipfilter',imcount); namewithext = strcat(name,'.png'); filename = strcat('C:\ipfilteredset',namewithext); fid1 = fopen(filename,'w'); imwrite(finaldestin,filename); fclose(fid1) fclose(fid); Error: ??? Error using ==> imwrite at 394 Can't open file "C:\ipfilteredset\ipfilter2.png" for writing. You may not have write permission. Error in ==> imarea>pushbutton6_Callback at 161 imwrite(finaldestin,filename); Error in ==> gui_mainfcn at 96 feval(varargin{:}); Will there be any use if I use fullfile() with imwrite() ? How can I save an image into a folder?? Thank you in advance for your suggestions. Regards, Dave.
From: ImageAnalyst on 2 Jul 2010 07:43 Dave: I prefer fullfile() but it won't make any difference in your case because you already have the full file name. Are you sure that folder exists? Check before out write with if ~exist('C:\ipfilteredset, 'dir') mkdir('C:\ipfilteredset); end or something like that. But the real reason it fails is that you're opening the very same file that imwrite is trying to create with fopen, which creates the file and puts a lock on it so that when imwrite comes along, it can't do anything because you have opened/locked that file. Just let imwrite do its job without trying fopen() & fclose(). -ImageAnalyst
|
Pages: 1 Prev: www.jerseysexport.com Wholesale NHL Jerseys,Blackhawks Jersey Next: Adapt function problem |