annotate scripts/io/Tiff.m @ 31171:8bf3fa6b6977

Tiff: added readRGBAStrip and readRGBATile methods * __tiff__.cc: added internal functions for reading strips and tiles using LibTIFF's RGBA interface. * Tiff.m: added readRGBAStrip and readRGBATile methods to the Tiff class and added unit tests for the ne methods.
author magedrifaat <magedrifaat@gmail.com>
date Sun, 14 Aug 2022 02:40:03 +0200
parents 72a159bc5a4c
children 3f5f1404af8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31161
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
1 ## PKG_ADD: __tiff_set_errors_enabled__ (false);
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
2
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
3 classdef Tiff < handle
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
4 properties (Constant = true)
31159
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
5 TagID = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
6 "SubFileType", 254,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
7 "ImageWidth", 256,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
8 "ImageLength", 257,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
9 "BitsPerSample", 258,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
10 "Compression", 259,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
11 "Photometric", 262,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
12 "Thresholding", 263,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
13 "FillOrder", 266,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
14 "DocumentName", 269,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
15 "ImageDescription", 270,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
16 "Make", 271,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
17 "Model", 272,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
18 "StripOffsets", 273,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
19 "Orientation", 274,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
20 "SamplesPerPixel", 277,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
21 "RowsPerStrip", 278,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
22 "StripByteCounts", 279,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
23 "MinSampleValue", 280,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
24 "MaxSampleValue", 281,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
25 "XResolution", 282,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
26 "YResolution", 283,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
27 "PlanarConfiguration", 284,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
28 "PageName", 285,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
29 "XPosition", 286,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
30 "YPosition", 287,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
31 "GrayResponseUnit", 290,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
32 'GrayResponseCurve', 291,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
33 "Group3Options", 292,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
34 "Group4Options", 293,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
35 "ResolutionUnit", 296,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
36 "PageNumber", 297,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
37 "TransferFunction", 301,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
38 "Software", 305,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
39 "DateTime", 306,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
40 "Artist", 315,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
41 "HostComputer", 316,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
42 "WhitePoint", 318,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
43 "PrimaryChromaticities", 319,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
44 "ColorMap", 320,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
45 "HalfToneHints", 321,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
46 "TileWidth", 322,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
47 "TileLength", 323,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
48 "TileOffsets", 324,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
49 "TileByteCounts", 325,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
50 "SubIFD", 330,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
51 "InkSet", 332,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
52 "InkNames", 333,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
53 "NumberOfInks", 334,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
54 "DotRange", 336,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
55 "TargetPrinter", 337,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
56 "ExtraSamples", 338,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
57 "SampleFormat", 339,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
58 "SMinSampleValue", 340,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
59 "SMaxSampleValue", 341,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
60 "YCbCrCoefficients", 529,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
61 "YCbCrSubSampling", 530,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
62 "YCbCrPositioning", 531,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
63 "ReferenceBlackWhite", 532,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
64 "XMP", 700,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
65 "ImageDepth", 32997,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
66 "Copyright", 33432,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
67 "RichTIFFIPTC", 33723,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
68 "Photoshop", 34377,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
69 "ICCProfile", 34675,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
70 "SToNits", 37439,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
71 "JPEGQuality", 65537,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
72 "JPEGColorMode", 65538,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
73 "ZipQuality", 65557,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
74 "SGILogDataFmt", 65560
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
75 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
76
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
77 Compression = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
78 "None", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
79 "CCITTRLE", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
80 "CCITTFax3", 3,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
81 "CCITTFax4", 4,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
82 "LZW", 5,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
83 "OJPEG", 6,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
84 "JPEG", 7,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
85 "AdobeDeflate", 8,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
86 "Next", 32766,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
87 "CCITTRLEW", 32771,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
88 "PackBits", 32773,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
89 "Thunderscan", 32809,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
90 "IT8CTPad", 32895,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
91 "IT8LW", 32896,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
92 "IT8MP", 32897,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
93 "IT8BL", 32898,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
94 "PixarFilm", 32908,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
95 "PixarLog", 32909,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
96 "Deflate", 32946,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
97 "DCS", 32947,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
98 "JBIG", 34661,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
99 "SGILog", 34676,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
100 "SGILog24", 34677,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
101 "JPEG2000", 34712,
31161
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
102 # Not defined in LibTIFF, only in matlab
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
103 # TODO(maged): test these compression methods
31159
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
104 "JPEG2000_SVS_YCbCr", 33003,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
105 "JPEG2000_SVS_RGB", 33005
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
106 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
107
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
108 ExtraSamples = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
109 "Unspecified", 0,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
110 "AssociatedAlpha", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
111 "UnassociatedAlpha", 2
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
112 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
113
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
114 Group3Options = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
115 "Encoding2D", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
116 "Uncompressed", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
117 "FillBits", 4
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
118 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
119
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
120 InkSet = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
121 "CMYK", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
122 "MultiInk", 2
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
123 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
124
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
125 JPEGColorMode = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
126 "Raw", 0,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
127 "RGB", 1
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
128 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
129
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
130 Orientation = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
131 "TopLeft", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
132 "TopRight", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
133 "BottomRight", 3,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
134 "BottomLeft", 4,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
135 "LeftTop", 5,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
136 "RightTop", 6,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
137 "RightBottom", 7,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
138 "LeftBottom", 8
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
139 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
140
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
141 Photometric = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
142 "MinIsWhite", 0,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
143 "MinIsBlack", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
144 "RGB", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
145 "Palette", 3,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
146 "Mask", 4,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
147 "Separated", 5,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
148 "YCbCr", 6,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
149 "CIELab", 8,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
150 "ICCLab", 9,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
151 "ITULab", 10,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
152 "LogL", 32844,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
153 "LogLUV", 32845,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
154 "CFA", 32803,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
155 "LinearRaw", 34892
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
156 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
157
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
158 PlanarConfiguration = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
159 "Chunky", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
160 "Separate", 2
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
161 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
162
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
163 ResolutionUnit = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
164 "None", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
165 "Inch", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
166 "Centimeter", 3
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
167 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
168
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
169 SampleFormat = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
170 "UInt", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
171 "Int", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
172 "IEEEFP", 3
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
173 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
174
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
175 SGILogDataFmt = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
176 "Float", 0,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
177 "Bits8", 3
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
178 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
179
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
180 SubFileType = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
181 "Default", 0,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
182 "ReducedImage", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
183 "Page", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
184 "Mask", 4
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
185 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
186
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
187 Thresholding = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
188 "BiLevel", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
189 "HalfTone", 2,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
190 "ErrorDiffuse", 3
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
191 );
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
192
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
193 YCbCrPositioning = struct (
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
194 "Centered", 1,
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
195 "Cosited", 2
e960e3a3b3f6 Tiff.m: added structs for tag value enums to the Tiff class.
magedrifaat <magedrifaat@gmail.com>
parents: 31158
diff changeset
196 );
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
197 endproperties
31092
a736190ce738 Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff changeset
198
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
199 properties (Access = private)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
200 tiff_handle;
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
201 closed=false;
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
202 endproperties
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
203
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
204 methods
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
205 function t = Tiff (filename, mode="r")
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
206 if (nargin == 0 || nargin > 2)
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
207 % print_usage();
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
208 error("Usage: Tiff(filename[, mode])");
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
209 endif
31092
a736190ce738 Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff changeset
210
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
211 t.tiff_handle = __open_tiff__ (filename, mode);
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
212 endfunction
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
213
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
214 function close (t)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
215 if (! t.closed)
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
216 __close_tiff__ (t.tiff_handle);
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
217 t.closed = true;
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
218 endif
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
219 endfunction
31092
a736190ce738 Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff changeset
220
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
221 function tag = getTag (t, tag_name)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
222 if (t.closed)
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
223 error ("Image file was closed");
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
224 endif
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
225 tag = __tiff_get_tag__ (t.tiff_handle, tag_name);
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
226 endfunction
31092
a736190ce738 Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff changeset
227
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
228 function setTag (t, varargin)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
229 if (t.closed)
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
230 error ("Image file was closed");
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
231 endif
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
232 __tiff_set_tag__ (t.tiff_handle, varargin{:});
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
233 endfunction
31126
7851c5b9c950 Tiff: implemented writeEncodedStrip function for writing a strip to an image
magedrifaat <magedrifaat@gmail.com>
parents: 31124
diff changeset
234
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
235 function argout = read (t)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
236 if (t.closed)
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
237 error ("Image file was closed");
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
238 endif
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
239 argout = __tiff_read__ (t.tiff_handle);
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
240 endfunction
31092
a736190ce738 Added the Tiff classdef files to octave
magedrifaat <magedrifaat@gmail.com>
parents:
diff changeset
241
31157
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
242 function stripData = readEncodedStrip (t, stripNumber)
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
243 if (t.closed)
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
244 error ("Image file was closed");
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
245 endif
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
246 stripData = __tiff_read_encoded_strip__ (t.tiff_handle, stripNumber);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
247 endfunction
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
248
31158
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
249 function tileData = readEncodedTile (t, tileNumber)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
250 if (t.closed)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
251 error ("Image file was closed");
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
252 endif
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
253 tileData = __tiff_read_encoded_tile__ (t.tiff_handle, tileNumber);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
254 endfunction
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
255
31170
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
256 function [RGB, alpha] = readRGBAImage (t)
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
257 if (t.closed)
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
258 error ("Image file was closed");
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
259 endif
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
260 [RGB, alpha] = __tiff_read_rgba_image__ (t.tiff_handle);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
261 endfunction
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
262
31171
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
263 function [RGB, alpha] = readRGBAStrip (t, row)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
264 if (t.closed)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
265 error ("Image file was closed");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
266 endif
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
267 [RGB, alpha] = __tiff_read_rgba_strip__ (t.tiff_handle, row);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
268 endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
269
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
270 function [RGB, alpha] = readRGBATile (t, row, col)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
271 if (t.closed)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
272 error ("Image file was closed");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
273 endif
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
274 [RGB, alpha] = __tiff_read_rgba_tile__ (t.tiff_handle, row, col);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
275 endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
276
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
277 function write (t, imageData)
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
278 if (t.closed)
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
279 error ("Image file was closed");
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
280 endif
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
281 __tiff_write__ (t.tiff_handle, imageData);
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
282 endfunction
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
283
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
284 function writeEncodedStrip (t, stripNumber, imageData)
31141
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
285 if (t.closed)
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
286 error ("Image file was closed");
af4519cbfcae Tiff.m: prevented calling methods after the image file is closed.
magedrifaat <magedrifaat@gmail.com>
parents: 31140
diff changeset
287 endif
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
288 __tiff_write_encoded_strip__ (t.tiff_handle, stripNumber, imageData);
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
289 endfunction
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
290
31146
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
291 function writeEncodedTile (t, tileNumber, imageData)
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
292 if (t.closed)
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
293 error ("Image file was closed");
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
294 endif
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
295 __tiff_write_encoded_tile__ (t.tiff_handle, tileNumber, imageData);
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
296 endfunction
50402b8dfb4a Tiff: added writeEncodedTile function for writing tiled images
magedrifaat <magedrifaat@gmail.com>
parents: 31145
diff changeset
297
31148
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
298 function tf = isTiled (t)
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
299 if (t.closed)
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
300 error ("Image file was closed");
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
301 endif
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
302 tf = __tiff_is_tiled__ (t.tiff_handle);
31148
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
303 endfunction
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
304
31149
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
305 function numStrips = numberOfStrips (t)
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
306 if (t.closed)
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
307 error ("Image file was closed");
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
308 endif
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
309 numStrips = __tiff_number_of_strips__ (t.tiff_handle);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
310 endfunction
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
311
31151
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
312 function numTiles = numberOfTiles (t)
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
313 if (t.closed)
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
314 error ("Image file was closed");
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
315 endif
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
316 numTiles = __tiff_number_of_tiles__ (t.tiff_handle);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
317 endfunction
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
318
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
319 function stripNumber = computeStrip (t, varargin)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
320 if (t.closed)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
321 error ("Image file was closed");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
322 endif
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
323 stripNumber = __tiff_compute_strip__ (t.tiff_handle, varargin{:});
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
324 endfunction
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
325
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
326 function tileNumber = computeTile (t, varargin)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
327 if (t.closed)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
328 error ("Image file was closed");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
329 endif
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
330 tileNumber = __tiff_compute_tile__ (t.tiff_handle, varargin{:});
31149
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
331 endfunction
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
332
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
333 % TODO(maged): add documentation and make print_usage work
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
334 endmethods
31151
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
335
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
336 methods (Static = true)
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
337 function versionString = getVersion()
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
338 versionString = __tiff_version__ ();
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
339 endfunction
31161
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
340
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
341 function setLibTIFFErrorsEnabled(state)
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
342 __tiff_set_errors_enabled__ (state);
b731c8f6db95 Tiff: added setLibTIFFErrorsEnabled method to enable/disable LibTIFF errors
magedrifaat <magedrifaat@gmail.com>
parents: 31159
diff changeset
343 endfunction
31151
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
344 endmethods
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
345 endclassdef
31124
e8d1cc309bc9 Tiff: added initial implementation of setTag function for scalar tags
magedrifaat <magedrifaat@gmail.com>
parents: 31116
diff changeset
346
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
347 %!function file_wrapper (fn)
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
348 %! filename = [tempname() ".tif"];
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
349 %! unwind_protect
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
350 %! fn (filename);
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
351 %! unwind_protect_cleanup
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
352 %! unlink (filename);
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
353 %! end_unwind_protect
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
354 %!endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
355
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
356 %!function verify_data (filename, data, ex_size)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
357 %! img = Tiff (filename, "r");
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
358 %! data2 = img.read ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
359 %! assert (size (data2), ex_size);
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
360 %! assert (data2, resize (data, size (data2)));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
361 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
362 %!endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
363
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
364 ## test setTag and getTag for scalar tags
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
365 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
366 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
367 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
368 %! setTag (img, "ImageWidth", 2);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
369 %! val = getTag (img, "ImageWidth");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
370 %! assert (val, 2);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
371 %! assert (class (val), "double");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
372 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
373 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
374
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
375 ## test failure setTag and getTag unknown tag
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
376 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
377 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
378 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
379 %! fail ("getTag (img, \"ImageWidt\")", "Tiff tag not found");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
380 %! fail ("getTag (img, 999999)", "Tiff tag not found");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
381 %! fail ("setTag (img, \"ImageWidt\", 2)", "Tiff tag not found");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
382 %! fail ("setTag (img, 999999, 2)", "Tiff tag not found");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
383 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
384 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
385
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
386 ## test setTag structure input
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
387 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
388 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
389 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
390 %! setTag (img, struct ("ImageLength", 2, "ImageWidth", 2));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
391 %! assert (getTag (img, "ImageLength"), 2);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
392 %! assert (getTag (img, "ImageWidth"), 2);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
393 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
394 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
395
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
396 ## test failure setTag structure unknown tag
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
397 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
398 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
399 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
400 %! setTag (img, "ImageLength", 1);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
401 %! setTag (img, "ImageWidth", 1);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
402 %! fail ("setTag (img, struct (\"ImageLength\", 2, \"a\", 1, \"ImageWidth\", 2))",
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
403 %! "Tag a not found");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
404 %! assert (getTag (img, "ImageLength"), 2);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
405 %! assert (getTag (img, "ImageWidth"), 1);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
406 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
407 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
408
31169
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
409 ## test setTag array field
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
410 %!testif HAVE_TIFF
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
411 %! function test_fn (filename)
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
412 %! img = Tiff (filename, "w");
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
413 %! setTag (img, "YCbCrCoefficients", [1.5, 2.5, 3.5]);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
414 %! data = getTag (img, "YCbCrCoefficients");
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
415 %! assert (data, [1.5, 2.5, 3.5]);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
416 %! endfunction
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
417 %! file_wrapper (@test_fn);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
418
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
419 ## test setTag special field
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
420 %!testif HAVE_TIFF
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
421 %! function test_fn (filename)
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
422 %! img = Tiff (filename, "w");
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
423 %! setTag (img, "BitsPerSample", 8);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
424 %! cmap = reshape (1:768, [256, 3]) / 1024.0;
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
425 %! setTag (img, "ColorMap", cmap);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
426 %! assert (getTag (img, "ColorMap"), cmap, 1e-5);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
427 %! endfunction
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
428 %! file_wrapper (@test_fn);
ae41e14bf5c7 Tiff.m: added tests for array and special tags.
magedrifaat <magedrifaat@gmail.com>
parents: 31161
diff changeset
429
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
430 ## test failure invalid open mode/ invalid filename
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
431 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
432 %! fail ("Tiff (\"test.tif\", \"rh\")",
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
433 %! "Invalid mode for openning Tiff file: rh");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
434 %! fail ("Tiff ([tempname() \".tif\"], \"r\")", "Failed to open Tiff file");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
435
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
436 ## test one-pixel grayscale image
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
437 %!testif HAVE_TIFF
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
438 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
439 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
440 %! setTag (img, struct ("ImageLength", 1, "ImageWidth", 1,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
441 %! "BitsPerSample", 8));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
442 %! data = uint8 (randi (intmax ("uint8"), 1, 1));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
443 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
444 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
445 %! verify_data (filename, data, [1, 1]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
446 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
447 %! file_wrapper (@test_fn);
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
448
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
449 ## test failure to write to image without dimensions
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
450 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
451 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
452 %! img = Tiff (filename, "w");
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
453 %! data = uint8 (randi (intmax ("uint8"), 1, 1));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
454 %! fail ("writeEncodedStrip (img, 1, data)", "Failed to read image width");
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
455 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
456 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
457 %! file_wrapper (@test_fn);
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
458
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
459 ## test one row grayscale image
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
460 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
461 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
462 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
463 %! setTag (img, struct ("ImageLength", 1, "ImageWidth", 10,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
464 %! "BitsPerSample", 8));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
465 %! data = uint8 (reshape (1:10, [1, 10]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
466 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
467 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
468 %! verify_data (filename, data, [1, 10]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
469 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
470 %! file_wrapper (@test_fn);
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
471
31137
233130c0b1f6 Tiff writeEncodedStrip: changed strip dimension check behavior to mimic matlab
magedrifaat <magedrifaat@gmail.com>
parents: 31136
diff changeset
472 ## test wrong size of row
31132
c66f7c227e50 Tiff.m: added a test function and some base-case tests.
magedrifaat <magedrifaat@gmail.com>
parents: 31131
diff changeset
473 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
474 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
475 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
476 %! setTag (img, struct ("ImageLength", 1, "ImageWidth", 10,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
477 %! "BitsPerSample", 8));
31145
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
478 %! data = uint8 (reshape (1:13, [1, 13]));
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
479 %! fail ("writeEncodedStrip (img, 1, data)", "warning",
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
480 %! "The image width is 10 but the input has 13 columns.");
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
481 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
482 %! verify_data (filename, data, [1, 10]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
483 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
484 %! file_wrapper (@test_fn);
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
485
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
486 ## test one strip grayscale image
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
487 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
488 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
489 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
490 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
491 %! "BitsPerSample", 8));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
492 %! data = uint8 (reshape (1:100, [10, 10]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
493 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
494 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
495 %! verify_data (filename, data, [10, 10]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
496 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
497 %! file_wrapper (@test_fn);
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
498
31137
233130c0b1f6 Tiff writeEncodedStrip: changed strip dimension check behavior to mimic matlab
magedrifaat <magedrifaat@gmail.com>
parents: 31136
diff changeset
499 ## test wrong height of strip
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
500 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
501 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
502 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
503 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
504 %! "BitsPerSample", 8));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
505 %! data = uint8 (reshape (1:110, [11, 10]));
31145
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
506 %! fail ("writeEncodedStrip (img, 1, data)", "warning",
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
507 %! "The strip is composed of 10 rows but the input has 11 rows.");
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
508 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
509 %! verify_data (filename, data, [10, 10]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
510 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
511 %! file_wrapper (@test_fn);
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
512
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
513 ## test one strip RGB image chunky planes (RGBRGBRGB)
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
514 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
515 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
516 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
517 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
518 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
519 %! "PlanarConfiguration", 1,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
520 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
521 %! data = uint8 (reshape (1:300, [10, 10, 3]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
522 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
523 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
524 %! verify_data (filename, data, [10, 10, 3]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
525 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
526 %! file_wrapper (@test_fn);
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
527
31137
233130c0b1f6 Tiff writeEncodedStrip: changed strip dimension check behavior to mimic matlab
magedrifaat <magedrifaat@gmail.com>
parents: 31136
diff changeset
528 ## test wrong number of channels
31134
fc0366e009dd Tiff.m: added tests for 8-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31132
diff changeset
529 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
530 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
531 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
532 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
533 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
534 %! "PlanarConfiguration", 1,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
535 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
536 %! data = uint8 (reshape (1:400, [10, 10, 4]));
31145
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
537 %! fail ("writeEncodedStrip (img, 1, data)", "warning",
2e11f9cb30b8 Tiff writeEncodedStrip: added warning for input data larger than the size of the strip.
magedrifaat <magedrifaat@gmail.com>
parents: 31143
diff changeset
538 %! "The strip is composed of 3 channels but the input has 4 channels.");
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
539 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
540 %! verify_data (filename, data, [10, 10, 3]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
541 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
542 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
543
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
544 ## test one strip RGB image separate planes (RRRGGGBBB)
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
545 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
546 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
547 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
548 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
549 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
550 %! "PlanarConfiguration", 2,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
551 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
552 %! data = uint8 (reshape (1:300, [10, 10, 3]));
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
553 %! for i = 1:3
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
554 %! writeEncodedStrip (img, i, data(:,:,i));
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
555 %! endfor
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
556 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
557 %! verify_data (filename, data, [10, 10, 3]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
558 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
559 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
560
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
561 ## test 1-bit BiLevel image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
562 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
563 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
564 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
565 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
566 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
567 %! writeEncodedStrip (img, 1, data);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
568 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
569 %! verify_data (filename, data, [10, 10]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
570 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
571 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
572
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
573 ## test 16-bit grayscale image
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
574 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
575 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
576 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
577 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
578 %! "BitsPerSample", 16));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
579 %! data = uint16 (reshape (1:400, [20, 20]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
580 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
581 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
582 %! verify_data (filename, data, [20, 20]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
583 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
584 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
585
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
586 ## test 32-bit grayscale image
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
587 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
588 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
589 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
590 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
591 %! "BitsPerSample", 32));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
592 %! data = uint32 (reshape (1:400, [20, 20]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
593 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
594 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
595 %! verify_data (filename, data, [20, 20]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
596 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
597 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
598
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
599 ## test 16-bit RGB image
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
600 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
601 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
602 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
603 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
604 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
605 %! "PlanarConfiguration", 1,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
606 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
607 %! data = uint16 (reshape (1:1200, [20, 20, 3]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
608 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
609 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
610 %! verify_data (filename, data, [20, 20, 3]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
611 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
612 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
613
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
614 ## test 32-bit RGB image
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
615 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
616 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
617 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
618 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
619 %! "BitsPerSample", 32, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
620 %! "PlanarConfiguration", 1,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
621 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
622 %! data = uint32 (reshape (1:1200, [20, 20, 3]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
623 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
624 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
625 %! verify_data (filename, data, [20, 20, 3]);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
626 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
627 %! file_wrapper (@test_fn);
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
628
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
629 ## test failure unsupported bit-depth
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
630 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
631 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
632 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
633 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
634 %! "BitsPerSample", 24));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
635 %! data = uint16 (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
636 %! fail ("writeEncodedStrip (img, 1, data)", "Unsupported bit depth");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
637 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
638 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
639 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
640
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
641 ## test failure unsupported BiLevel number of channels
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
642 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
643 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
644 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
645 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
646 %! "SamplesPerPixel", 3));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
647 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
648 %! fail ("writeEncodedStrip (img, 1, data)",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
649 %! "Bi-Level images must have one channel only");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
650 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
651 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
652 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
653
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
654 ## test multi-strip BiLevel image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
655 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
656 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
657 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
658 %! setTag (img, struct ("ImageLength", 10, "ImageWidth", 10,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
659 %! "RowsPerStrip", 2));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
660 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
661 %! for strip = 1:5
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
662 %! writeEncodedStrip (img, strip, data(strip * 2 - 1: strip * 2, :));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
663 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
664 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
665 %! verify_data (filename, data, [10, 10]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
666 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
667 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
668
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
669 ## test multi-strip grayscale image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
670 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
671 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
672 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
673 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
674 %! "BitsPerSample", 16, "RowsPerStrip", 3));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
675 %! data = uint16 (reshape (1:400, [20, 20]));
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
676 %! for strip = 1:7
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
677 %! writeEncodedStrip (img, strip, data(strip * 3 - 2: min(strip * 3, 20), :));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
678 %! endfor
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
679 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
680 %! verify_data (filename, data, [20, 20]);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
681 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
682 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
683
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
684 ## test multi-strip RGB image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
685 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
686 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
687 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
688 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
689 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
690 %! "RowsPerStrip", 2, "PlanarConfiguration", 1,
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
691 %! "PhotometricInterpretation", 2));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
692 %! data = uint16 (reshape (1:1200, [20, 20, 3]));
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
693 %! for strip = 1:10
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
694 %! writeEncodedStrip (img, strip, data(strip * 2 - 1: strip * 2, :, :));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
695 %! endfor
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
696 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
697 %! verify_data (filename, data, [20, 20, 3]);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
698 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
699 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
700
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
701 ## test multi-strip RGB separate planes image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
702 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
703 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
704 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
705 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
706 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
707 %! "RowsPerStrip", 3, "PlanarConfiguration", 2,
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
708 %! "PhotometricInterpretation", 2));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
709 %! data = uint16 (reshape (1:1200, [20, 20, 3]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
710 %! strip = 1;
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
711 %! for sample = 1:3
31153
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
712 %! for row = 1:3:20
c66d6c7f025e Tiff: implemented write method for stripped images
magedrifaat <magedrifaat@gmail.com>
parents: 31151
diff changeset
713 %! writeEncodedStrip (img, strip, data(row: min(row + 2, 20), :, sample));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
714 %! strip = strip + 1;
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
715 %! endfor
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
716 %! endfor
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
717 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
718 %! verify_data (filename, data, [20, 20, 3]);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
719 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
720 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
721
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
722 ## test single-precision image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
723 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
724 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
725 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
726 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
727 %! "BitsPerSample", 32, "SampleFormat", 3));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
728 %! data = single (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
729 %! writeEncodedStrip (img, 1, data);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
730 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
731 %! verify_data (filename, data, [20, 20]);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
732 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
733 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
734
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
735 ## test double-precision image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
736 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
737 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
738 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
739 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
740 %! "BitsPerSample", 64, "SampleFormat", 3));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
741 %! data = double (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
742 %! writeEncodedStrip (img, 1, data);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
743 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
744 %! verify_data (filename, data, [20, 20]);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
745 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
746 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
747
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
748 ## test failure unsupported floating-point bit depth
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
749 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
750 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
751 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
752 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
753 %! "BitsPerSample", 16, "SampleFormat", 3));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
754 %! data = double (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
755 %! fail ("writeEncodedStrip (img, 1, data)",
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
756 %! "Floating point images are only supported for bit depths of 32 and 64");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
757 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
758 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
759 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
760
31135
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
761 ## test failure data-type and bit-depth mismatch
b7ffe64e0287 Tiff.m: added test for 16- and 32-bit grayscale and RGB images.
magedrifaat <magedrifaat@gmail.com>
parents: 31134
diff changeset
762 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
763 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
764 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
765 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
766 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
767 %! "PlanarConfiguration", 1,
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
768 %! "PhotometricInterpretation", 2));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
769 %! data = uint8 (reshape (1:1200, [20, 20, 3]));
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
770 %! fail ("writeEncodedStrip (img, 1, data)", "Only uint16 data is allowed for uint images with bit depth of 16");
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
771 %! img.close ();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
772 %! endfunction
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
773 %! file_wrapper (@test_fn);
31138
68762676dab1 Tiff writeEncodedStrip: prevent writing to a read-only file
magedrifaat <magedrifaat@gmail.com>
parents: 31137
diff changeset
774
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
775 ## test failure writing to img read-only file
31138
68762676dab1 Tiff writeEncodedStrip: prevent writing to a read-only file
magedrifaat <magedrifaat@gmail.com>
parents: 31137
diff changeset
776 %!testif HAVE_TIFF
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
777 %! function test_fn (filename)
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
778 %! img = Tiff (filename, "w");
31140
5f70efad6e2c Tiff setTag: added support for setting multiple tags at once using structs
magedrifaat <magedrifaat@gmail.com>
parents: 31139
diff changeset
779 %! setTag (img, struct ("ImageLength", 1, "ImageWidth", 1,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
780 %! "BitsPerSample", 8));
31139
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
781 %! data = uint8 (1);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
782 %! writeEncodedStrip (img, 1, data);
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
783 %! img.close();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
784 %! img = Tiff (filename, "r");
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
785 %! fail ("writeEncodedStrip(img, 1, [1])", "Can't write data to a file opened in read-only mode");
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
786 %! img.close();
3431a15b2c75 Tiff.m: refactored tests to use functions to reduce code repetition.
magedrifaat <magedrifaat@gmail.com>
parents: 31138
diff changeset
787 %! endfunction
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
788 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
789
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
790 ## test failure unsupported sample format
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
791 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
792 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
793 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
794 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
795 %! "BitsPerSample", 16, "SampleFormat", 5));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
796 %! data = double (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
797 %! fail ("writeEncodedStrip (img, 1, data)", "Unsupported sample format");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
798 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
799 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
800 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
801
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
802 ## test failure wrong strip number
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
803 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
804 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
805 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
806 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
807 %! "BitsPerSample", 16, "RowsPerStrip", 5));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
808 %! strip_data = uint16 (reshape (1:100, [5, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
809 %! fail ("writeEncodedStrip (img, 5, strip_data)",
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
810 %! "Strip number out of range");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
811 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
812 %! endfunction
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
813 %! file_wrapper (@test_fn);
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
814
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
815 ## test failure writing strips to tiled image
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
816 %!testif HAVE_TIFF
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
817 %! function test_fn (filename)
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
818 %! img = Tiff (filename, "w");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
819 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
820 %! "BitsPerSample", 16, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
821 %! "TileWidth", 16));
31143
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
822 %! data = uint8 (reshape (1:400, [20, 20]));
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
823 %! fail ("writeEncodedStrip (img, 1, data)",
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
824 %! "Can't write strips to a tiled image");
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
825 %! img.close ();
a68f2dadafee Tiff.m: added all remaining tests for implemented features.
magedrifaat <magedrifaat@gmail.com>
parents: 31141
diff changeset
826 %! endfunction
31147
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
827 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
828
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
829 ## test tiled BiLevel image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
830 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
831 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
832 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
833 %! setTag (img, struct ("ImageLength", 32, "ImageWidth", 32,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
834 %! "TileLength", 16, "TileWidth", 16));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
835 %! data = logical (repmat ([1,0,0,1,0,1,1,0], [32, 4]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
836 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
837 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
838 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
839 %! writeEncodedTile (img, tile, data(row:row+15, col:col+15));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
840 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
841 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
842 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
843 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
844 %! verify_data (filename, data, [32, 32]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
845 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
846 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
847
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
848 ## test tiled grayscale image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
849 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
850 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
851 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
852 %! setTag (img, struct ("ImageLength", 32, "ImageWidth", 32,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
853 %! "BitsPerSample", 16, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
854 %! "TileWidth", 16));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
855 %! data = uint16 (reshape (1:1024, [32, 32]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
856 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
857 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
858 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
859 %! writeEncodedTile (img, tile, data(row:row+15, col:col+15));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
860 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
861 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
862 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
863 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
864 %! verify_data (filename, data, [32, 32]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
865 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
866 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
867
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
868 ## test tiled grayscale image with padding
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
869 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
870 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
871 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
872 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
873 %! "BitsPerSample", 16, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
874 %! "TileWidth", 16));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
875 %! data = uint16 (reshape (1:400, [20, 20]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
876 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
877 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
878 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
879 %! writeEncodedTile (img, tile, data(row:min(row+15, 20),
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
880 %! col:min(col+15, 20)));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
881 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
882 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
883 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
884 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
885 %! verify_data (filename, data, [20, 20]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
886 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
887 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
888
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
889 ## test tiled RGB image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
890 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
891 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
892 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
893 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
894 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
895 %! "PlanarConfiguration", 1, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
896 %! "TileWidth", 16, "PhotometricInterpretation", 2));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
897 %! data = uint16 (reshape (1:1200, [20, 20, 3]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
898 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
899 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
900 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
901 %! writeEncodedTile (img, tile, data(row:min(row+15,20),
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
902 %! col:min(col+15,20), :));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
903 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
904 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
905 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
906 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
907 %! verify_data (filename, data, [20, 20, 3]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
908 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
909 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
910
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
911 ## test tiled RGB image separate planes
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
912 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
913 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
914 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
915 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
916 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
917 %! "PlanarConfiguration", 2, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
918 %! "TileWidth", 16, "PhotometricInterpretation", 2));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
919 %! data = uint16 (reshape (1:1200, [20, 20, 3]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
920 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
921 %! for channel=1:3
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
922 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
923 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
924 %! writeEncodedTile (img, tile, data(row:min(row+15,20),
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
925 %! col:min(col+15,20), channel));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
926 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
927 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
928 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
929 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
930 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
931 %! verify_data (filename, data, [20, 20, 3]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
932 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
933 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
934
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
935 ## test failure writing tiles to stripped image
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
936 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
937 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
938 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
939 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
940 %! "BitsPerSample", 16));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
941 %! data = uint8 (reshape (1:400, [20, 20]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
942 %! fail ("writeEncodedTile (img, 1, data)",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
943 %! "Can't write tiles to a stripped image");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
944 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
945 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
946 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
947
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
948 ## test tiled image wrong tile dimensions
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
949 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
950 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
951 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
952 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
953 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
954 %! "PlanarConfiguration", 1, "TileLength", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
955 %! "TileWidth", 16, "PhotometricInterpretation", 2));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
956 %! data = uint16 (reshape (1:1600, [20, 20, 4]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
957 %! tile = 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
958 %! for row = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
959 %! for col = 1:16:32
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
960 %! writeEncodedTile (img, tile, data(row:min(row+15,20),
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
961 %! col:min(col+15,20), 1:3));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
962 %! tile = tile + 1;
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
963 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
964 %! endfor
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
965 %! fail ("writeEncodedTile (img, 1, data(1:18,1:16,1:3))", "warning",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
966 %! "The tile is composed of 16 rows but input has 18 rows");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
967 %! fail ("writeEncodedTile (img, 1, data(1:16,1:20,1:3))", "warning",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
968 %! "The tile is composed of 16 columns but input has 20 columns");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
969 %! fail ("writeEncodedTile (img, 1, data(1:16,1:16,:))", "warning",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
970 %! "The tile is composed of 3 channels but input has 4 channels");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
971 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
972 %! verify_data (filename, data, [20, 20, 3]);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
973 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
974 %! file_wrapper (@test_fn);
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
975
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
976 ## test failure wrong tile number
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
977 %!testif HAVE_TIFF
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
978 %! function test_fn (filename)
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
979 %! img = Tiff (filename, "w");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
980 %! setTag (img, struct ("ImageLength", 20, "ImageWidth", 20,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
981 %! "BitsPerSample", 16, "TileWidth", 16,
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
982 %! "TileLength", 16));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
983 %! tile_data = uint16 (reshape (1:256, [16, 16]));
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
984 %! fail ("writeEncodedTile (img, 5, tile_data)",
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
985 %! "Tile number out of range");
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
986 %! img.close ();
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
987 %! endfunction
7af78a63d3c3 Tiff.m: added test for writing and reading tiled images.
magedrifaat <magedrifaat@gmail.com>
parents: 31146
diff changeset
988 %! file_wrapper (@test_fn);
31148
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
989
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
990 ## test isTiled returns the correct value
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
991 %!testif HAVE_TIFF
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
992 %! function test_fn (filename)
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
993 %! img = Tiff (filename, "w");
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
994 %! assert (isTiled (img), logical (0));
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
995 %! setTag (img, "TileLength", 16);
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
996 %! setTag (img, "TileWidth", 16);
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
997 %! assert (isTiled (img), logical (1));
4bc9a1938f9a Tiff: added isTiled method to check if the image is tiled or stripped
magedrifaat <magedrifaat@gmail.com>
parents: 31147
diff changeset
998 %! endfunction
31149
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
999 %! file_wrapper (@test_fn);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1000
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1001 ## test numberOfStrips returns the correct value
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1002 %!testif HAVE_TIFF
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1003 %! function test_fn (filename)
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1004 %! img = Tiff (filename, "w");
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1005 %! setTag (img, struct ("ImageWidth", 10, "ImageLength", 10));
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1006 %! assert (numberOfStrips (img), 1);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1007 %! setTag (img, "RowsPerStrip", 2);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1008 %! assert (numberOfStrips (img), 5);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1009 %! setTag (img, "RowsPerStrip", 4);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1010 %! assert (numberOfStrips (img), 3);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1011 %! setTag (img, "TileLength", 16);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1012 %! setTag (img, "TileWidth", 16);
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1013 %! fail ("numberOfStrips (img)", "The image is tiled not stripped");
d4dbc69f301e Tiff: implemented numberOfStrips method
magedrifaat <magedrifaat@gmail.com>
parents: 31148
diff changeset
1014 %! endfunction
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1015 %! file_wrapper (@test_fn);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1016
31151
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1017 ## test numberOfTiles returns the correct value
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1018 %!testif HAVE_TIFF
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1019 %! function test_fn (filename)
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1020 %! img = Tiff (filename, "w");
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1021 %! setTag (img, struct ("ImageWidth", 20, "ImageLength", 20,
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1022 %! "TileLength", 16, "TileWidth", 16));
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1023 %! assert (numberOfTiles (img), 4);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1024 %! setTag (img, "TileLength", 32);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1025 %! assert (numberOfTiles (img), 2);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1026 %! setTag (img, "TileWidth", 32);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1027 %! assert (numberOfTiles (img), 1);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1028 %! img = Tiff (filename, "w");
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1029 %! fail ("numberOfTiles (img)", "The image is stripped not tiled");
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1030 %! endfunction
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1031 %! file_wrapper (@test_fn);
6fb54834aa93 Tiff: added numberOfTiles and getVersion methods
magedrifaat <magedrifaat@gmail.com>
parents: 31150
diff changeset
1032
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1033 ## test computeStrip returns the correct value
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1034 %!testif HAVE_TIFF
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1035 %! function test_fn (filename)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1036 %! img = Tiff (filename, "w");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1037 %! setTag (img, struct ("ImageWidth", 10, "ImageLength", 10,
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1038 %! "RowsPerStrip", 2, "BitsPerSample", 8,
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1039 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1));
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1040 %! assert (computeStrip (img, 1), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1041 %! assert (computeStrip (img, 2), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1042 %! assert (computeStrip (img, 0), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1043 %! assert (computeStrip (img, 10), 5);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1044 %! assert (computeStrip (img, 11), 5);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1045 %! setTag (img, "PlanarConfiguration", 2);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1046 %! ## This is need for the tag to take effect, should be
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1047 %! ## replaced by rewriteDirectory
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1048 %! writeEncodedStrip (img, 1, uint8 (reshape (1:20, [2, 10])));
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1049 %! assert (computeStrip (img, 1, 2), 6);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1050 %! assert (computeStrip (img, 100, 1), 5);
31171
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1051 %! img = Tiff (filename, "w");
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1052 %! setTag (img, "TileWidth", 16);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1053 %! setTag (img, "TileLength", 16);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1054 %! fail ("computeStrip (img, 1, 1)", "The image is tiled not stripped");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1055 %! endfunction
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1056 %! file_wrapper (@test_fn);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1057
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1058 ## test computeTile returns the correct value
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1059 %!testif HAVE_TIFF
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1060 %! function test_fn (filename)
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1061 %! img = Tiff (filename, "w");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1062 %! setTag (img, struct ("ImageWidth", 20, "ImageLength", 20,
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1063 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1064 %! "TileLength", 16, "TileWidth", 16,
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1065 %! "PlanarConfiguration", 1));
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1066 %! assert (computeTile (img, [1, 1]), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1067 %! assert (computeTile (img, [2, 2]), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1068 %! assert (computeTile (img, [0, 0]), 1);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1069 %! assert (computeTile (img, [8, 17]), 2);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1070 %! assert (computeTile (img, [19, 10]), 3);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1071 %! assert (computeTile (img, [17, 17]), 4);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1072 %! assert (computeTile (img, [100, 100]), 4);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1073 %! setTag (img, "PlanarConfiguration", 2);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1074 %! ## This is need for the tag to take effect, should be
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1075 %! ## replaced by rewriteDirectory
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1076 %! writeEncodedTile (img, 1, uint8 (reshape (1:256, [16, 16])));
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1077 %! assert (computeTile (img, [1, 1], 2), 5);
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1078 %! assert (computeTile (img, [100, 100], 1), 4);
31171
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1079 %! img = Tiff (filename, "w");
31150
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1080 %! fail ("computeTile (img, 1, 1)", "The image is stripped not tiled");
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1081 %! endfunction
6bede2d6f273 Tiff: added computeStrip and computeTile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31149
diff changeset
1082 %! file_wrapper (@test_fn);
31154
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1083
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1084 ## test write method one pixel bilevel image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1085 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1086 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1087 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1088 %! setTag(img, struct ("ImageLength", 1, "ImageWidth", 1));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1089 %! write (img, logical ([1]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1090 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1091 %! verify_data (filename, logical ([1]), [1, 1]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1092 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1093 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1094
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1095 ## test write method one strip bilevel image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1096 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1097 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1098 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1099 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1100 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1101 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1102 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1103 %! verify_data (filename, data, [10, 10]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1104 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1105 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1106
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1107 ## test write method multi-strip bilevel image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1108 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1109 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1110 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1111 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1112 %! "RowsPerStrip", 3));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1113 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1114 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1115 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1116 %! verify_data (filename, data, [10, 10]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1117 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1118 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1119
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1120 ## test write method one pixel grayscale image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1121 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1122 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1123 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1124 %! setTag(img, struct ("ImageLength", 1, "ImageWidth", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1125 %! "BitsPerSample", 8));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1126 %! write (img, uint8 ([255]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1127 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1128 %! verify_data (filename, uint8 ([255]), [1, 1]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1129 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1130 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1131
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1132 ## test write method one strip grayscale image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1133 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1134 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1135 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1136 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1137 %! "BitsPerSample", 8));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1138 %! data = uint8 (reshape (1:100, [10, 10]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1139 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1140 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1141 %! verify_data (filename, data, [10, 10]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1142 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1143 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1144
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1145 ## test write method multi-strip grayscale image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1146 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1147 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1148 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1149 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1150 %! "BitsPerSample", 8, "RowsPerStrip", 3));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1151 %! data = uint8 (reshape (1:100, [10, 10]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1152 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1153 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1154 %! verify_data (filename, data, [10, 10]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1155 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1156 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1157
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1158 ## test write method multi-strip RGB image chunky
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1159 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1160 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1161 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1162 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1163 %! "BitsPerSample", 8, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1164 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1165 %! "PhotometricInterpretation", 2));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1166 %! data = uint8 (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1167 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1168 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1169 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1170 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1171 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1172
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1173 ## test write method multi-strip RGB image separate
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1174 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1175 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1176 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1177 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1178 %! "BitsPerSample", 8, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1179 %! "SamplesPerPixel", 3, "PlanarConfiguration", 2,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1180 %! "PhotometricInterpretation", 2));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1181 %! data = uint8 (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1182 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1183 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1184 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1185 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1186 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1187
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1188 ## test write method 16-bit multi-strip image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1189 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1190 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1191 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1192 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1193 %! "BitsPerSample", 16, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1194 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1195 %! "PhotometricInterpretation", 2));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1196 %! data = uint16 (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1197 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1198 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1199 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1200 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1201 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1202
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1203 ## test write method 32-bit multi-strip image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1204 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1205 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1206 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1207 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1208 %! "BitsPerSample", 32, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1209 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1210 %! "PhotometricInterpretation", 2));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1211 %! data = uint32 (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1212 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1213 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1214 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1215 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1216 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1217
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1218 ## test write method single-precision image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1219 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1220 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1221 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1222 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1223 %! "BitsPerSample", 32, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1224 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1225 %! "PhotometricInterpretation", 2, "SampleFormat", 3));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1226 %! data = single (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1227 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1228 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1229 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1230 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1231 %! file_wrapper (@test_fn);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1232
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1233 ## test write method single-precision image
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1234 %!testif HAVE_TIFF
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1235 %! function test_fn (filename)
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1236 %! img = Tiff (filename, "w");
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1237 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1238 %! "BitsPerSample", 64, "RowsPerStrip", 3,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1239 %! "SamplesPerPixel", 3, "PlanarConfiguration", 1,
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1240 %! "PhotometricInterpretation", 2, "SampleFormat", 3));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1241 %! data = double (reshape (1:300, [10, 10, 3]));
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1242 %! write (img, data);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1243 %! img.close();
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1244 %! verify_data (filename, data, [10, 10, 3]);
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1245 %! endfunction
828b7cc9aa36 Tiff write: added support for BiLevel stripped images and added unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31153
diff changeset
1246 %! file_wrapper (@test_fn);
31156
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1247
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1248 ## test write method tiled BiLevel image
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1249 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1250 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1251 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1252 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1253 %! "TileWidth", 16, "TileLength", 16));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1254 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [40, 4]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1255 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1256 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1257 %! verify_data (filename, data, [40, 40]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1258 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1259 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1260
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1261 ## test write method tiled grayscale image
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1262 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1263 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1264 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1265 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1266 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1267 %! "BitsPerSample", 16));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1268 %! data = uint16 (reshape (1:1600, [40, 40]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1269 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1270 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1271 %! verify_data (filename, data, [40, 40]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1272 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1273 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1274
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1275 ## test write method tiled RGB image chunky
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1276 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1277 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1278 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1279 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1280 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1281 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1282 %! "PhotometricInterpretation", 2,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1283 %! "PlanarConfiguration", 1));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1284 %! data = uint16 (reshape (1:4800, [40, 40, 3]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1285 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1286 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1287 %! verify_data (filename, data, [40, 40, 3]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1288 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1289 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1290
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1291 ## test write method tiled RGB image separate
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1292 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1293 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1294 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1295 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1296 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1297 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1298 %! "PhotometricInterpretation", 2,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1299 %! "PlanarConfiguration", 2));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1300 %! data = uint16 (reshape (1:4800, [40, 40, 3]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1301 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1302 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1303 %! verify_data (filename, data, [40, 40, 3]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1304 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1305 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1306
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1307 ## test write method 32-bit tiled image
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1308 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1309 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1310 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1311 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1312 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1313 %! "BitsPerSample", 32, "SamplesPerPixel", 3,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1314 %! "PhotometricInterpretation", 2,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1315 %! "PlanarConfiguration", 1));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1316 %! data = uint32 (reshape (1:4800, [40, 40, 3]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1317 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1318 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1319 %! verify_data (filename, data, [40, 40, 3]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1320 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1321 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1322
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1323 ## test write method single-precision tiled image
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1324 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1325 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1326 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1327 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1328 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1329 %! "BitsPerSample", 32, "SamplesPerPixel", 3,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1330 %! "PhotometricInterpretation", 2,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1331 %! "PlanarConfiguration", 1, "SampleFormat", 3));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1332 %! data = single (reshape (1:4800, [40, 40, 3]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1333 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1334 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1335 %! verify_data (filename, data, [40, 40, 3]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1336 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1337 %! file_wrapper (@test_fn);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1338
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1339 ## test write method double-precision tiled image
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1340 %!testif HAVE_TIFF
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1341 %! function test_fn (filename)
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1342 %! img = Tiff (filename, "w");
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1343 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1344 %! "TileWidth", 16, "TileLength", 16,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1345 %! "BitsPerSample", 64, "SamplesPerPixel", 3,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1346 %! "PhotometricInterpretation", 2,
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1347 %! "PlanarConfiguration", 1, "SampleFormat", 3));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1348 %! data = double (reshape (1:4800, [40, 40, 3]));
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1349 %! write (img, data);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1350 %! img.close();
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1351 %! verify_data (filename, data, [40, 40, 3]);
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1352 %! endfunction
1e633a093faa Tiff write: added support for logical tile images and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31154
diff changeset
1353 %! file_wrapper (@test_fn);
31157
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1354
31158
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1355 ## test readEncodedStrip BiLevel image
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1356 %!testif HAVE_TIFF
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1357 %! function test_fn (filename)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1358 %! img = Tiff (filename, "w");
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1359 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1360 %! "RowsPerStrip", 6));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1361 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [10, 1]));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1362 %! write (img, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1363 %! s1 = readEncodedStrip (img, 1);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1364 %! s2 = readEncodedStrip (img, 2);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1365 %! assert ([s1;s2], data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1366 %! img.close();
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1367 %! endfunction
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1368 %! file_wrapper (@test_fn);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1369
31157
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1370 ## test readEncodedStrip RGB Chunky
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1371 %!testif HAVE_TIFF
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1372 %! function test_fn (filename)
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1373 %! img = Tiff (filename, "w");
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1374 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1375 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1376 %! "PhotometricInterpretation", 2, "RowsPerStrip", 6,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1377 %! "PlanarConfiguration", 1));
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1378 %! data = uint16 (reshape (1:300, [10, 10, 3]));
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1379 %! write (img, data);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1380 %! s1 = readEncodedStrip (img, 1);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1381 %! s2 = readEncodedStrip (img, 2);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1382 %! assert ([s1;s2], data);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1383 %! img.close();
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1384 %! endfunction
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1385 %! file_wrapper (@test_fn);
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1386
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1387 ## test readEncodedStrip RGB Separated
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1388 %!testif HAVE_TIFF
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1389 %! function test_fn (filename)
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1390 %! img = Tiff (filename, "w");
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1391 %! setTag(img, struct ("ImageLength", 10, "ImageWidth", 10,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1392 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1393 %! "PhotometricInterpretation", 2, "RowsPerStrip", 6,
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1394 %! "PlanarConfiguration", 2));
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1395 %! data = uint16 (reshape (1:300, [10, 10, 3]));
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1396 %! write (img, data);
31158
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1397 %! s = cell (6, 1);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1398 %! for i=1:6
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1399 %! s{i} = readEncodedStrip (img, i);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1400 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1401 %! data2 = cat (3, [s{1}; s{2}], [s{3}; s{4}], [s{5}; s{6}]);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1402 %! assert (data2, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1403 %! img.close();
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1404 %! endfunction
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1405 %! file_wrapper (@test_fn);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1406
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1407 ## test readEncodedTile BiLevel image
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1408 %!testif HAVE_TIFF
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1409 %! function test_fn (filename)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1410 %! img = Tiff (filename, "w");
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1411 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1412 %! "TileWidth", 16, "TileLength", 16));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1413 %! data = logical (repmat ([1,0,0,0,1,0,1,1,1,0], [40, 4]));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1414 %! write (img, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1415 %! t = cell (9, 1);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1416 %! for i=1:9
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1417 %! t{i} = readEncodedTile (img, i);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1418 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1419 %! data2 = cat(1, cat (2, t{1}, t{2}, t{3}), cat (2, t{4}, t{5}, t{6}),
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1420 %! cat (2, t{7}, t{8}, t{9}));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1421 %! assert (data2, data);
31157
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1422 %! img.close();
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1423 %! endfunction
dc3d2744916d Tiff: added readEncodedStrip method and corresponding unit tests
magedrifaat <magedrifaat@gmail.com>
parents: 31156
diff changeset
1424 %! file_wrapper (@test_fn);
31158
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1425
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1426 ## test readEncodedTile RGB Chunky
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1427 %!testif HAVE_TIFF
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1428 %! function test_fn (filename)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1429 %! img = Tiff (filename, "w");
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1430 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1431 %! "TileWidth", 16, "TileLength", 16,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1432 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1433 %! "PhotometricInterpretation", 2,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1434 %! "PlanarConfiguration", 1));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1435 %! data = uint16 (reshape (1:4800, [40, 40, 3]));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1436 %! write (img, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1437 %! t = cell (9, 1);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1438 %! for i=1:9
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1439 %! t{i} = readEncodedTile (img, i);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1440 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1441 %! data2 = cat(1, cat (2, t{1}, t{2}, t{3}), cat (2, t{4}, t{5}, t{6}),
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1442 %! cat (2, t{7}, t{8}, t{9}));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1443 %! assert (data2, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1444 %! img.close();
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1445 %! endfunction
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1446 %! file_wrapper (@test_fn);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1447
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1448 ## test readEncodedTile RGB Separated
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1449 %!testif HAVE_TIFF
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1450 %! function test_fn (filename)
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1451 %! img = Tiff (filename, "w");
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1452 %! setTag(img, struct ("ImageLength", 40, "ImageWidth", 40,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1453 %! "TileWidth", 16, "TileLength", 16,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1454 %! "BitsPerSample", 16, "SamplesPerPixel", 3,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1455 %! "PhotometricInterpretation", 2,
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1456 %! "PlanarConfiguration", 2));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1457 %! data = uint16 (reshape (1:4800, [40, 40, 3]));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1458 %! write (img, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1459 %! data2 = uint16 (zeros (40, 40, 3));
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1460 %! tile = 1;
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1461 %! for sample=1:3
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1462 %! for row=1:16:40
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1463 %! for col=1:16:40
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1464 %! data2(row: min(40, row + 15), col: min(40, col + 15), sample)...
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1465 %! = readEncodedTile(img, tile);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1466 %! tile += 1;
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1467 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1468 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1469 %! endfor
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1470 %! assert (data2, data);
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1471 %! img.close();
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1472 %! endfunction
f2ae7763739a Tiff: added writeEncodedTile method to read tiles from image
magedrifaat <magedrifaat@gmail.com>
parents: 31157
diff changeset
1473 %! file_wrapper (@test_fn);
31170
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1474
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1475 ## test readRGBAImage
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1476 %!testif HAVE_TIFF
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1477 %! function test_fn (filename)
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1478 %! img = Tiff (filename, "w");
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1479 %! setTag(img, struct (
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1480 %! "ImageLength", 10, "ImageWidth", 10,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1481 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1482 %! "PhotometricInterpretation", 2,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1483 %! "PlanarConfiguration", 1
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1484 %! ));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1485 %! data = uint8 (reshape (1:300, [10, 10, 3]));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1486 %! write (img, data);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1487 %! [rgb, alpha] = readRGBAImage (img);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1488 %! assert (rgb, data);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1489 %! assert (alpha, uint8 (repmat ([255], [10, 10])));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1490 %! endfunction
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1491 %! file_wrapper (@test_fn);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1492
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1493 ## test readRGBAImage with alpha
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1494 %!testif HAVE_TIFF
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1495 %! function test_fn (filename)
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1496 %! img = Tiff (filename, "w");
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1497 %! setTag(img, struct (
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1498 %! "ImageLength", 10, "ImageWidth", 10,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1499 %! "BitsPerSample", 8, "SamplesPerPixel", 4,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1500 %! "PhotometricInterpretation", 2,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1501 %! "PlanarConfiguration", 1,
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1502 %! "ExtraSamples", 1
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1503 %! ));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1504 %! data = uint8 (randi ([0,255], [10, 10, 4]));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1505 %! write (img, data);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1506 %! [rgb, alpha] = readRGBAImage (img);
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1507 %! assert (rgb, data(:,:,1:3));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1508 %! assert (alpha, data(:,:,4));
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1509 %! endfunction
72a159bc5a4c Tiff: added readRGBAImage method to read image using the RGBA interface
magedrifaat <magedrifaat@gmail.com>
parents: 31169
diff changeset
1510 %! file_wrapper (@test_fn);
31171
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1511
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1512 ## test readRGBAStrip
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1513 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1514 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1515 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1516 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1517 %! "ImageLength", 10, "ImageWidth", 10,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1518 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1519 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1520 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1521 %! "RowsPerStrip", 3
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1522 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1523 %! data = uint8 (randi ([0,255], [10, 10, 3]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1524 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1525 %! [rgb, alpha] = readRGBAStrip (img, 1);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1526 %! assert (rgb, data(1:3,:,:));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1527 %! assert (alpha, uint8 (repmat ([255], [3, 10])));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1528 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1529 %! file_wrapper (@test_fn);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1530
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1531 ## test readRGBAStrip boundary strip
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1532 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1533 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1534 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1535 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1536 %! "ImageLength", 10, "ImageWidth", 10,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1537 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1538 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1539 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1540 %! "RowsPerStrip", 3
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1541 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1542 %! data = uint8 (randi ([0,255], [10, 10, 3]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1543 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1544 %! [rgb, alpha] = readRGBAStrip (img, 10);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1545 %! assert (rgb, data(10,:,:));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1546 %! assert (alpha, uint8 (repmat ([255], [1, 10])));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1547 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1548 %! file_wrapper (@test_fn);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1549
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1550 ## test readRGBAStrip with alpha
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1551 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1552 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1553 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1554 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1555 %! "ImageLength", 10, "ImageWidth", 10,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1556 %! "BitsPerSample", 8, "SamplesPerPixel", 4,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1557 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1558 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1559 %! "RowsPerStrip", 3,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1560 %! "ExtraSamples", 1
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1561 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1562 %! data = uint8 (randi ([0,255], [10, 10, 4]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1563 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1564 %! [rgb, alpha] = readRGBAStrip (img, 1);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1565 %! assert (rgb, data(1:3,:, 1:3));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1566 %! assert (alpha, data (1:3, :, 4));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1567 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1568 %! file_wrapper (@test_fn);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1569
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1570 ## test readRGBATile
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1571 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1572 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1573 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1574 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1575 %! "ImageLength", 40, "ImageWidth", 40,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1576 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1577 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1578 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1579 %! "TileLength", 16, "TileWidth", 32
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1580 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1581 %! data = uint8 (randi ([0,255], [40, 40, 3]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1582 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1583 %! [rgb, alpha] = readRGBATile (img, 1, 1);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1584 %! assert (rgb, data(1:16,1:32,:));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1585 %! assert (alpha, uint8 (repmat ([255], [16, 32])));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1586 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1587 %! file_wrapper (@test_fn);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1588
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1589 ## test readRGBATile boundary tile
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1590 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1591 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1592 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1593 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1594 %! "ImageLength", 40, "ImageWidth", 40,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1595 %! "BitsPerSample", 8, "SamplesPerPixel", 3,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1596 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1597 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1598 %! "TileLength", 16, "TileWidth", 32
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1599 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1600 %! data = uint8 (randi ([0,255], [40, 40, 3]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1601 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1602 %! [rgb, alpha] = readRGBATile (img, 40, 40);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1603 %! assert (rgb, data(33:end,33:end,:));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1604 %! assert (alpha, uint8 (repmat ([255], [8, 8])));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1605 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1606 %! file_wrapper (@test_fn);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1607
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1608 ## test readRGBATile ith alpha
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1609 %!testif HAVE_TIFF
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1610 %! function test_fn (filename)
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1611 %! img = Tiff (filename, "w");
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1612 %! setTag(img, struct (
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1613 %! "ImageLength", 40, "ImageWidth", 40,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1614 %! "BitsPerSample", 8, "SamplesPerPixel", 4,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1615 %! "PhotometricInterpretation", 2,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1616 %! "PlanarConfiguration", 1,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1617 %! "TileLength", 16, "TileWidth", 32,
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1618 %! "ExtraSamples", 1
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1619 %! ));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1620 %! data = uint8 (randi ([0,255], [40, 40, 4]));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1621 %! write (img, data);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1622 %! [rgb, alpha] = readRGBATile (img, 1, 1);
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1623 %! assert (rgb, data(1:16,1:32,1:3));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1624 %! assert (alpha, data(1:16,1:32,4));
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1625 %! endfunction
8bf3fa6b6977 Tiff: added readRGBAStrip and readRGBATile methods
magedrifaat <magedrifaat@gmail.com>
parents: 31170
diff changeset
1626 %! file_wrapper (@test_fn);