summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/matlab/read_image8u_bmp.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/matlab/read_image8u_bmp.m')
-rwxr-xr-xSD-VBS/common/matlab/read_image8u_bmp.m66
1 files changed, 0 insertions, 66 deletions
diff --git a/SD-VBS/common/matlab/read_image8u_bmp.m b/SD-VBS/common/matlab/read_image8u_bmp.m
deleted file mode 100755
index 28e5834..0000000
--- a/SD-VBS/common/matlab/read_image8u_bmp.m
+++ /dev/null
@@ -1,66 +0,0 @@
1function image = read_image8u_bmp(pathName)
2
3 fid = fopen (pathName,'r'); %FILE *input;
4% //check for the input FILE pointer
5 if(fid == 0)
6
7 disp('File pointer error');
8
9 else
10% start of header information
11 BYTES_PER_PIXEL=3;
12 signature = fread(fid,2,'char=>char');
13 file_size = fread(fid,1,'int=>int');
14 reserved1 = fread(fid,1,'short=>short');
15 reserved2 = fread(fid,1,'short=>short');
16 loc_of_bitmap = fread(fid, 1, 'int=>double');
17 size_of_infoheader = fread(fid,1,'int=>int');
18 width = fread(fid,1,'int=>double');
19 height = fread(fid,1,'int=>double');
20 number_of_planes = fread(fid,1,'short=>short');
21 bits_per_pixel = fread(fid,1,'short=>short');
22 compression_method = fread(fid,1,'int=>int');
23 bytes_of_bitmap = fread(fid,1,'int=>int');
24 hori_reso = fread(fid,1,'int=>int');
25 vert_reso = fread(fid,1,'int=>int');
26 no_of_colors = fread(fid,1,'int=>int');
27 no_of_imp_colors = fread(fid,1,'int=>int');
28
29 nRows = height;
30 nCols = width;
31 nPitch = nCols;
32 pad = 4 - (nCols*BYTES_PER_PIXEL - 4*floor(nCols*BYTES_PER_PIXEL/4)); %bitmap multiple-of-4 requirement
33
34 pixSize=nRows *nCols * 3;
35
36 % Conditions to check whether the BMP is interleaved and handling few exceptions
37 if (nRows <= 0 || nCols <= 0 || signature(1) ~= 'B' || signature(2) ~= 'M' || bits_per_pixel ~=24)
38 disp ('Error');
39 return;
40 else
41
42%read image
43% fseek(fid,loc_of_bitmap,'bof');
44
45 for nI = nRows:-1:1
46 for nJ=1:nCols
47
48 image(nI,nJ,3) = fread(fid,1,'char=>uint8'); %B
49 image(nI,nJ,2) = fread(fid,1,'char=>uint8'); %G
50 image(nI,nJ,1) = fread(fid,1,'char=>uint8'); %R
51
52 end
53 if pad~=4
54 for i=1:pad
55 fread(fid,1);
56 end
57 end
58 end
59 imshow(image);
60 imwrite(image,'image.bmp');
61 fclose(fid);
62
63 end
64
65 end
66 \ No newline at end of file