Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

IMWRITE fails to write tiff stack

45 views
Skip to first unread message

Zachary

unread,
Aug 24, 2010, 7:30:21 PM8/24/10
to
I'm running MATLAB 2009a as part of a robotic microscope setup. Recently, I changed out the hardware and OS for a beefier system running Windows 7 32 bit. This was great, since all the hardware worked fine and everything moved faster, but I ran into a nasty problem saving image stacks that had been acquired.

Randomly, IMWRITE would fail to write an image. In the middle of the loop to save an image stack, it would give up and state: "Couldn't open 'bug.tif' for writing." Baffled, I checked the permissions of the drive, disabled Windows search indexing, nothing helped. I tried writing to an external USB drive, and that seemed to work for a while, but then the problem came back. I put some try-catch statements in my code to retry the write in cases of an error. Again, sometimes the second try IMWRITE in the catch block would work, other times not.

I whittled my code down to a little M-file which exhibits the behavior on my Windows 7 32 bit system. I've not seen this file get an error under XP or on any of my Macs.

Any suggestions or help would be greatly appreciated. Here's the code followed by an example run on the machine in question.

Thanks,

-Zack

I = rand([400 400 61],'double')*1500;
tname = 'bug.tif';
tname2 = 'bug2.tif';

clc
for j = 1:52
tic
for i=1:size(I,3)
imwrite(uint16(I(:,:,i)),tname,'WriteMode','append','Compression','none');
end
for i=1:size(I,3)
imwrite(uint16(I(:,:,i)),tname2,'WriteMode','append','Compression','none');
end
t = toc;
disp(['Frame ' num2str(j) ' took ' num2str(t) ' seconds to write.']);
drawnow
end

% Matlab 2009a Student Edition
% Windows 7 32 Bit

% Frame 1 took 0.73855 seconds to write.
% Frame 2 took 0.83714 seconds to write.
% Frame 3 took 1.0112 seconds to write.
% Frame 4 took 1.0875 seconds to write.
% Frame 5 took 1.1901 seconds to write.
% Frame 6 took 2.8044 seconds to write.
% Frame 7 took 1.417 seconds to write.
% Frame 8 took 1.5514 seconds to write.
% Frame 9 took 2.7905 seconds to write.
% Frame 10 took 2.3628 seconds to write.
% Frame 11 took 4.5118 seconds to write.
% Frame 12 took 2.8204 seconds to write.
% Frame 13 took 3.4613 seconds to write.
% Frame 14 took 3.1589 seconds to write.
% Frame 15 took 2.5999 seconds to write.
% Frame 16 took 5.6436 seconds to write.
% Frame 17 took 2.3387 seconds to write.
% Frame 18 took 2.5935 seconds to write.
% ??? Error using ==> writetif at 100
% Couldn't open 'bug.tif' for writing.
%
% Error in ==> imwrite at 429
% feval(fmt_s.write, data, map, filename, paramPairs{:});
%
% Error in ==> imwrite_bug at 9
% imwrite(uint16(I(:,:,i)),tname,'WriteMode','append','Compression','none');

% File size of bug.tif after crash: 348,193 KB

0 new messages