# HG changeset patch # User magedrifaat # Date 1662491549 -7200 # Node ID edbd725ee76c2fa02eda8090e13f4ab1493202ba # Parent e83a62df599b560204ed80fce5e510b920fa2466 imwrite: fixed tests to reflect alpha channel behavior for Tiff images * scripts/image/imwrite.m: modified tests to correctly handled the new behavior for alpha channel in Tiff images. * scripts/image/imread.m: added a note in the function documentation about the alpha channel behavior for Tiff images. diff -r e83a62df599b -r edbd725ee76c scripts/image/imread.m --- a/scripts/image/imread.m Tue Sep 06 20:57:50 2022 +0200 +++ b/scripts/image/imread.m Tue Sep 06 21:12:29 2022 +0200 @@ -49,6 +49,12 @@ ## the first. In some rare cases this may be incorrect and @code{imfinfo} can ## be used to obtain the colormap of each image. ## +## For TIFF images, the transaprency channel is appended to the rest of the +## channels in @var{img}, and @var{alpha} is always empty for matlab +## compatibility. To differentiate between RGBA and CMYK images, check +## @code{ColorType} or @code{PhotometricInterpretation} fields in the output +## of @code{imfinfo}. +## ## See the Octave manual for more information in representing images. ## (@pxref{Representing Images}) ## diff -r e83a62df599b -r edbd725ee76c scripts/image/imwrite.m --- a/scripts/image/imwrite.m Tue Sep 06 20:57:50 2022 +0200 +++ b/scripts/image/imwrite.m Tue Sep 06 21:12:29 2022 +0200 @@ -160,8 +160,8 @@ %! gray = randi (255, 10, 10, 1, "uint8"); %! alpha = randi (255, 10, 10, 1, "uint8"); %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); -%! assert (r, gray); -%! assert (a, alpha); +%! assert (r, cat (3, gray, alpha)); +%! assert (a, []); ## multipage grayscale uint8 images %!testif HAVE_MAGICK @@ -174,8 +174,8 @@ %! gray = randi (255, 10, 10, 3, 5, "uint8"); %! alpha = randi (255, 10, 10, 1, 5, "uint8"); %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); -%! assert (r, gray); -%! assert (a, alpha); +%! assert (r, cat (3, gray, alpha)); +%! assert (a, []); ## typical usage with RGB uint8 images %!testif HAVE_MAGICK @@ -188,8 +188,8 @@ %! rgb = randi (255, 10, 10, 3, "uint8"); %! alpha = randi (255, 10, 10, 1, "uint8"); %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); -%! assert (r, rgb); -%! assert (a, alpha); +%! assert (r, cat (3, rgb, alpha)); +%! assert (a, []); ## multipage RGB uint8 images %!testif HAVE_MAGICK @@ -202,8 +202,8 @@ %! rgb = randi (255, 10, 10, 3, 5, "uint8"); %! alpha = randi (255, 10, 10, 1, 5, "uint8"); %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); -%! assert (r, rgb); -%! assert (a, alpha); +%! assert (r, cat (3, rgb, alpha)); +%! assert (a, []); %!testif HAVE_MAGICK %! gray = repmat (uint8 (0:255), 100, 1);