# HG changeset patch # User magedrifaat # Date 1659909979 -7200 # Node ID e960e3a3b3f63fcbbe2ab30216b30144e27231ee # Parent f2ae7763739a4d5b38c87874dfa9d8335b5162a8 Tiff.m: added structs for tag value enums to the Tiff class. diff -r f2ae7763739a -r e960e3a3b3f6 libinterp/dldfcn/__tiff__.cc --- a/libinterp/dldfcn/__tiff__.cc Sat Aug 06 21:59:26 2022 +0200 +++ b/libinterp/dldfcn/__tiff__.cc Mon Aug 08 00:06:19 2022 +0200 @@ -203,7 +203,6 @@ // ASSUMES tiled image and tile_no is a valid zero-based tile // index for the tif image - // TODO(maged): check matlab behavior // TODO(maged): refactor into a function? uint32_t tile_width, tile_height; if (! TIFFGetField (tif, TIFFTAG_TILELENGTH, &tile_height)) @@ -303,7 +302,7 @@ image_data->samples_per_pixel); else if (image_data->planar_configuration == PLANARCONFIG_SEPARATE) corrected_dims = dim_vector (corrected_height, corrected_width); - // TODO(maged): confirm matlab behavior + tile_data.resize (corrected_dims); return octave_value (tile_data); @@ -1701,7 +1700,9 @@ void write_image (TIFF *tif, T pixel_data, tiff_image_data *image_data) { - // TODO(maged): check behavior in matlab + // TODO(maged): matlab sets the remaining to zero for less width and height + // and issues a warning for larger widths but not for larger height? + // and errors for less or more number of channels if (image_data->height != pixel_data.dim1 () || image_data->width != pixel_data.dim2 () || pixel_data.ndims () > 3 @@ -1969,7 +1970,6 @@ if (TIFFIsTiled (tif)) error ("The image is tiled not stripped"); - // TODO(maged): what is the behavior in matlab uint32_t strip_no; if (args(1).is_scalar_type ()) strip_no = args(1).uint32_scalar_value (); @@ -2005,7 +2005,6 @@ if (! TIFFIsTiled (tif)) error ("The image is stripped not tiled"); - // TODO(maged): what is the behavior in matlab uint32_t tile_no; if (args(1).is_scalar_type ()) tile_no = args(1).uint32_scalar_value (); diff -r f2ae7763739a -r e960e3a3b3f6 scripts/io/Tiff.m --- a/scripts/io/Tiff.m Sat Aug 06 21:59:26 2022 +0200 +++ b/scripts/io/Tiff.m Mon Aug 08 00:06:19 2022 +0200 @@ -1,76 +1,195 @@ classdef Tiff < handle properties (Constant = true) - TagID = struct( - "SubFileType", 254, - "ImageWidth", 256, - "ImageLength", 257, - "BitsPerSample", 258, - "Compression", 259, - "Photometric", 262, - "Thresholding", 263, - "FillOrder", 266, - "DocumentName", 269, - "ImageDescription", 270, - "Make", 271, - "Model", 272, - "StripOffsets", 273, - "Orientation", 274, - "SamplesPerPixel", 277, - "RowsPerStrip", 278, - "StripByteCounts", 279, - "MinSampleValue", 280, - "MaxSampleValue", 281, - "XResolution", 282, - "YResolution", 283, - "PlanarConfiguration", 284, - "PageName", 285, - "XPosition", 286, - "YPosition", 287, - "GrayResponseUnit", 290, - 'GrayResponseCurve', 291, - "Group3Options", 292, - "Group4Options", 293, - "ResolutionUnit", 296, - "PageNumber", 297, - "TransferFunction", 301, - "Software", 305, - "DateTime", 306, - "Artist", 315, - "HostComputer", 316, - "WhitePoint", 318, - "PrimaryChromaticities", 319, - "ColorMap", 320, - "HalfToneHints", 321, - "TileWidth", 322, - "TileLength", 323, - "TileOffsets", 324, - "TileByteCounts", 325, - "SubIFD", 330, - "InkSet", 332, - "InkNames", 333, - "NumberOfInks", 334, - "DotRange", 336, - "TargetPrinter", 337, - "ExtraSamples", 338, - "SampleFormat", 339, - "SMinSampleValue", 340, - "SMaxSampleValue", 341, - "YCbCrCoefficients", 529, - "YCbCrSubSampling", 530, - "YCbCrPositioning", 531, - "ReferenceBlackWhite", 532, - "XMP", 700, - "ImageDepth", 32997, - "Copyright", 33432, - "RichTIFFIPTC", 33723, - "Photoshop", 34377, - "ICCProfile", 34675, - "SToNits", 37439, - "JPEGQuality", 65537, - "JPEGColorMode", 65538, - "ZipQuality", 65557, - "SGILogDataFmt", 65560 - ) + TagID = struct ( + "SubFileType", 254, + "ImageWidth", 256, + "ImageLength", 257, + "BitsPerSample", 258, + "Compression", 259, + "Photometric", 262, + "Thresholding", 263, + "FillOrder", 266, + "DocumentName", 269, + "ImageDescription", 270, + "Make", 271, + "Model", 272, + "StripOffsets", 273, + "Orientation", 274, + "SamplesPerPixel", 277, + "RowsPerStrip", 278, + "StripByteCounts", 279, + "MinSampleValue", 280, + "MaxSampleValue", 281, + "XResolution", 282, + "YResolution", 283, + "PlanarConfiguration", 284, + "PageName", 285, + "XPosition", 286, + "YPosition", 287, + "GrayResponseUnit", 290, + 'GrayResponseCurve', 291, + "Group3Options", 292, + "Group4Options", 293, + "ResolutionUnit", 296, + "PageNumber", 297, + "TransferFunction", 301, + "Software", 305, + "DateTime", 306, + "Artist", 315, + "HostComputer", 316, + "WhitePoint", 318, + "PrimaryChromaticities", 319, + "ColorMap", 320, + "HalfToneHints", 321, + "TileWidth", 322, + "TileLength", 323, + "TileOffsets", 324, + "TileByteCounts", 325, + "SubIFD", 330, + "InkSet", 332, + "InkNames", 333, + "NumberOfInks", 334, + "DotRange", 336, + "TargetPrinter", 337, + "ExtraSamples", 338, + "SampleFormat", 339, + "SMinSampleValue", 340, + "SMaxSampleValue", 341, + "YCbCrCoefficients", 529, + "YCbCrSubSampling", 530, + "YCbCrPositioning", 531, + "ReferenceBlackWhite", 532, + "XMP", 700, + "ImageDepth", 32997, + "Copyright", 33432, + "RichTIFFIPTC", 33723, + "Photoshop", 34377, + "ICCProfile", 34675, + "SToNits", 37439, + "JPEGQuality", 65537, + "JPEGColorMode", 65538, + "ZipQuality", 65557, + "SGILogDataFmt", 65560 + ); + + Compression = struct ( + "None", 1, + "CCITTRLE", 2, + "CCITTFax3", 3, + "CCITTFax4", 4, + "LZW", 5, + "OJPEG", 6, + "JPEG", 7, + "AdobeDeflate", 8, + "Next", 32766, + "CCITTRLEW", 32771, + "PackBits", 32773, + "Thunderscan", 32809, + "IT8CTPad", 32895, + "IT8LW", 32896, + "IT8MP", 32897, + "IT8BL", 32898, + "PixarFilm", 32908, + "PixarLog", 32909, + "Deflate", 32946, + "DCS", 32947, + "JBIG", 34661, + "SGILog", 34676, + "SGILog24", 34677, + "JPEG2000", 34712, + "JPEG2000_SVS_YCbCr", 33003, + "JPEG2000_SVS_RGB", 33005 + ); + + ExtraSamples = struct ( + "Unspecified", 0, + "AssociatedAlpha", 1, + "UnassociatedAlpha", 2 + ); + + Group3Options = struct ( + "Encoding2D", 1, + "Uncompressed", 2, + "FillBits", 4 + ); + + InkSet = struct ( + "CMYK", 1, + "MultiInk", 2 + ); + + JPEGColorMode = struct ( + "Raw", 0, + "RGB", 1 + ); + + Orientation = struct ( + "TopLeft", 1, + "TopRight", 2, + "BottomRight", 3, + "BottomLeft", 4, + "LeftTop", 5, + "RightTop", 6, + "RightBottom", 7, + "LeftBottom", 8 + ); + + Photometric = struct ( + "MinIsWhite", 0, + "MinIsBlack", 1, + "RGB", 2, + "Palette", 3, + "Mask", 4, + "Separated", 5, + "YCbCr", 6, + "CIELab", 8, + "ICCLab", 9, + "ITULab", 10, + "LogL", 32844, + "LogLUV", 32845, + "CFA", 32803, + "LinearRaw", 34892 + ); + + PlanarConfiguration = struct ( + "Chunky", 1, + "Separate", 2 + ); + + ResolutionUnit = struct ( + "None", 1, + "Inch", 2, + "Centimeter", 3 + ); + + SampleFormat = struct ( + "UInt", 1, + "Int", 2, + "IEEEFP", 3 + ); + + SGILogDataFmt = struct ( + "Float", 0, + "Bits8", 3 + ); + + SubFileType = struct ( + "Default", 0, + "ReducedImage", 1, + "Page", 2, + "Mask", 4 + ); + + Thresholding = struct ( + "BiLevel", 1, + "HalfTone", 2, + "ErrorDiffuse", 3 + ); + + YCbCrPositioning = struct ( + "Centered", 1, + "Cosited", 2 + ); endproperties properties (Access = private)