matlab crashes when running code on ~600 images
Mostrar comentarios más antiguos
Hi,
i want to remove duplicate images from my portable hardDisk (win 7, 64 bit)
i have ~ 650 images, and i don't care about efficiency / running time (+ don't want to deal with memory issue's) so i wrote the following naive code with double for loop, that loads and compare each image separately, and if the images are equal adds to one filename "_double".
the code works on small amount of images, but running over ~ 600 matlab crashes:
tic
dir_path = pwd;
list = dir([dir_path '\*.jpg']);
DupCounter = 0;
fprintf('list size is %d \n',length(list));
fprintf('processing file ');
for i=1:length(list)-1
fprintf(' %d,', i);
if strfind( list(i).name,'_double')
continue;
end
currImage = imread(list(i).name);
for j=i+1:length(list)
if strfind( list(j).name,'_double')
continue;
end
nextImage = imread(list(j).name);
if isequal(currImage, nextImage)
movefile(list(j).name,strrep(list(j).name,'.jpg','_double.jpg')) % rename
list(j).name = strrep(list(j).name,'.jpg','_double.jpg'); % change name also in the list
DupCounter = DupCounter +1;
end
end
end
msg = sprintf('Total # duplicate frames: %d', DupCounter);
disp(msg)
toc
i get this massage:
Problem signature:
Problem Event Name: APPCRASH
Application Name: MATLAB.exe
Application Version: 8.1.0.0
Application Timestamp: 50f7698f
Fault Module Name: rjpg8c.mexw64
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 50f771f6
Exception Code: c0000005
Exception Offset: 00000000000048fd
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1037
Additional Information 1: 2779
Additional Information 2: 277989f6aaa1d3ad64e8aeb5379db6ad
Additional Information 3: afc2
Additional Information 4: afc2f6520a6347247fd65c23f35ecb40
any idea?
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 1 de Sept. de 2015
Inside the j loop, have it print out the image it's processing.
fprintf('Comparing image#%d: %s, with image #%d: %s\n', ...
i, list(i).name, j, list(j).name);
In case it's crashing in the i loop on hte currImage line, but before the j loop, write out the i image name there:
fprintf('About to compare all other images to image #%d,: %s', i, list(i).name);
See if it's crashing on the same one all the time. See if you can call imread() on that image from the command line:
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!