Problem with imwrite when creating multiple Image Files

1 view (last 30 days)
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

Accepted Answer

Dimitris M
Dimitris M on 12 May 2012
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 Comment
Image Analyst
Image Analyst on 12 May 2012
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

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 12 May 2012
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 Comments
Dimitris M
Dimitris M on 12 May 2012
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 on 12 May 2012
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.

Sign in to comment.


Dimitris M
Dimitris M on 12 May 2012
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

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!