/
recompress_BID.m
32 lines (26 loc) · 1.16 KB
/
recompress_BID.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
% The Blurrerd Image Database (BID) is available from
% http://www02.smt.ufrj.br/~eduardo/ImageDatabase.htm
% BID contains JPEG images. As of January 2020, MATLAB's imread function
% has unpredictable problems when reading these images. Sometimes the
% images are read correctly, and sometimes an unknown problem occurs.
%
% This script moves the BID images into a subdirectory (named "original")
% and recompresses each image as a lossless JPEG. This ensures no
% additional impairment is added to the image.
%
success = mkdir([bid_dataset.path 'original\']);
if ~success
error('could not make subdirectory %soriginal', bid_dataset.path);
end
for cnt=1:length(bid_dataset.media)
success = movefile([bid_dataset.path bid_dataset.media(cnt).file], ...
[bid_dataset.path 'original\']);
if ~success
error('could not move file %s into subdirectory', bid_dataset.media(cnt).file);
end
end
for cnt=1:length(bid_dataset.media)
img = imread([bid_dataset.path 'original\' bid_dataset.media(cnt).file], 'jpg');
imwrite(img, [bid_dataset.path bid_dataset.media(cnt).file], 'jpg', ...
'Quality', 100, 'Mode', 'lossless');
end