Problem with imwrite when creating multiple Image Files

1 次查看(过去 30 天)
Hello
I am encountering a strange problem during a process of saving multiple image files in my hard disk.
More specifically the problem occurs while I am processing some photos and the saving them sequentially. As I have seen the problem occurs always when the sequence arrives in the 13th Image (strange!).
It seems strange to me as this work for the previous images and only on this step, that follows exact the same procedure (is done automatically) I have the error. Do you have any idea what could it be ?
The error I am taking is :
You may not have write permission.
Error in ==> Automatization at 479
imwrite(Seg_Out_1{2,Num_Seg},[ImageExpDir,sprintf(Exp_Name_2,Num_Seg,a,b,c,d,e,f,g,h,i,j,k)],'tif');
Thank you in advance

采纳的回答

Dimitris M
Dimitris M 2012-5-12
Hello
I just found out something. The problem is that the name of the sprintf function is too big. So when I minimize the size know works.
Is there any limit is the name that you can give to a file using sprintf function ?
Or maybe also that windows do not allow so large names for their image files too !
  1 个评论
Image Analyst
Image Analyst 2012-5-12
That doesn't make sense. The name of the sprintf() function is 7 characters. Windows has a maximum length of 260 characters for filenames. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

请先登录,再进行评论。

更多回答(2 个)

Image Analyst
Image Analyst 2012-5-12
That does not look like a proper sprintf() statement. Where is your format string? And why not use fullfile() instead of [,]? Try creating the filename in advance and printing it out to the command line so you can see what it is. Something like
baseFileName = sprintf('%s%d%d%d%d%d%d%d%d%d%d%d%d.tif', ...
Exp_Name_2,Num_Seg,a,b,c,d,e,f,g,h,i,j,k)
fullFileName = fullfile(ImageExpDir, baseFileName)
imwrite(Seg_Out_1{2,Num_Seg}, fullFileName);
  2 个评论
Dimitris M
Dimitris M 2012-5-12
Hello
I did the modification you suggested and I still get the same error. It is still very strange to me as I create 4 images in every segmentation step. These have been already 12 times created sequentially without any problem and still on the 13th iteration I get this error.
Any other suggestions ?
Thank you
Image Analyst
Image Analyst 2012-5-12
What was the filename when it bombed? I can't really debug much until you decide to share more code. I think there's something you're not telling us. Perhaps one of the a-k variables is not an integer or there's some other mismatch in the variables and the format specifier string. Or perhaps there's some character in filename that is not a valid character for files, such as : / \ ? * etc. or some non printable character such as hex 0 - 31 or something like that.

请先登录,再进行评论。


Dimitris M
Dimitris M 2012-5-12
I am not sure what was the problem but know the algorithm really works so I don't really know what to say about this !
Anyway thanks for your help ~!
Greetings from Greece

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by