MATLAB: Imwrite fails for small images less than 64 rows high

Image Processing Toolboximwrite

If I create an unsigned 16 bit array which is greater than 8192 columns wide and try to write it as a tiff image, it seems like it needs to be at least 64 rows high or Matlab 2014a throws an exception. To get around it, the 'RowsPerStrip' tag needs to be set manually to an integer value.
e.g:
x = ones([63 8192], 'uint16');
imwrite(x, 'C:\test\test.tif', 'tiff', 'Compression', 'none');
works fine.
BUT:
x = ones([63 8193], 'uint16');
imwrite(x, 'C:\test\test.tif', 'tiff', 'Compression', 'none');
gives an exception:
Error using wtifc
TIFF library error - '_TIFFVSetField: 4x8000.tif: Bad value 0 for "RowsPerStrip" tag.'
HOWEVER:
x = ones([64 8193], 'uint16');
imwrite(x, 'C:\test\test.tif', 'tiff', 'Compression', 'none');
works fine.
ALSO:
x = ones([63 8193], 'uint16');
imwrite(x, 'C:\test\test.tif', 'tiff', 'Compression', 'none', 'RowsPerStrip', 16);
works fine.
This was not a problem in 2011b

Best Answer

This looks like a bug.
Please contact MathWorks Tech Support by creating a Service Request: