Mercurial > octave-libtiff
comparison scripts/image/imwrite.m @ 31211:edbd725ee76c
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.
author | magedrifaat <magedrifaat@gmail.com> |
---|---|
date | Tue, 06 Sep 2022 21:12:29 +0200 |
parents | 796f54d4ddbf |
children |
comparison
equal
deleted
inserted
replaced
31210:e83a62df599b | 31211:edbd725ee76c |
---|---|
158 ## grayscale uint8 images with alpha channel | 158 ## grayscale uint8 images with alpha channel |
159 %!testif HAVE_MAGICK | 159 %!testif HAVE_MAGICK |
160 %! gray = randi (255, 10, 10, 1, "uint8"); | 160 %! gray = randi (255, 10, 10, 1, "uint8"); |
161 %! alpha = randi (255, 10, 10, 1, "uint8"); | 161 %! alpha = randi (255, 10, 10, 1, "uint8"); |
162 %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); | 162 %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); |
163 %! assert (r, gray); | 163 %! assert (r, cat (3, gray, alpha)); |
164 %! assert (a, alpha); | 164 %! assert (a, []); |
165 | 165 |
166 ## multipage grayscale uint8 images | 166 ## multipage grayscale uint8 images |
167 %!testif HAVE_MAGICK | 167 %!testif HAVE_MAGICK |
168 %! gray = randi (255, 10, 10, 1, 5, "uint8"); | 168 %! gray = randi (255, 10, 10, 1, 5, "uint8"); |
169 %! r = write_and_read (".tif", gray); | 169 %! r = write_and_read (".tif", gray); |
172 ## multipage RGB uint8 images with alpha channel | 172 ## multipage RGB uint8 images with alpha channel |
173 %!testif HAVE_MAGICK | 173 %!testif HAVE_MAGICK |
174 %! gray = randi (255, 10, 10, 3, 5, "uint8"); | 174 %! gray = randi (255, 10, 10, 3, 5, "uint8"); |
175 %! alpha = randi (255, 10, 10, 1, 5, "uint8"); | 175 %! alpha = randi (255, 10, 10, 1, 5, "uint8"); |
176 %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); | 176 %! [r, ~, a] = write_and_read (".tif", gray, "Alpha", alpha); |
177 %! assert (r, gray); | 177 %! assert (r, cat (3, gray, alpha)); |
178 %! assert (a, alpha); | 178 %! assert (a, []); |
179 | 179 |
180 ## typical usage with RGB uint8 images | 180 ## typical usage with RGB uint8 images |
181 %!testif HAVE_MAGICK | 181 %!testif HAVE_MAGICK |
182 %! rgb = randi (255, 10, 10, 3, "uint8"); | 182 %! rgb = randi (255, 10, 10, 3, "uint8"); |
183 %! r = write_and_read (".tif", rgb); | 183 %! r = write_and_read (".tif", rgb); |
186 ## RGB uint8 images with alpha channel | 186 ## RGB uint8 images with alpha channel |
187 %!testif HAVE_MAGICK | 187 %!testif HAVE_MAGICK |
188 %! rgb = randi (255, 10, 10, 3, "uint8"); | 188 %! rgb = randi (255, 10, 10, 3, "uint8"); |
189 %! alpha = randi (255, 10, 10, 1, "uint8"); | 189 %! alpha = randi (255, 10, 10, 1, "uint8"); |
190 %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); | 190 %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); |
191 %! assert (r, rgb); | 191 %! assert (r, cat (3, rgb, alpha)); |
192 %! assert (a, alpha); | 192 %! assert (a, []); |
193 | 193 |
194 ## multipage RGB uint8 images | 194 ## multipage RGB uint8 images |
195 %!testif HAVE_MAGICK | 195 %!testif HAVE_MAGICK |
196 %! rgb = randi (255, 10, 10, 3, 5, "uint8"); | 196 %! rgb = randi (255, 10, 10, 3, 5, "uint8"); |
197 %! r = write_and_read (".tif", rgb); | 197 %! r = write_and_read (".tif", rgb); |
200 ## multipage RGB uint8 images with alpha channel | 200 ## multipage RGB uint8 images with alpha channel |
201 %!testif HAVE_MAGICK | 201 %!testif HAVE_MAGICK |
202 %! rgb = randi (255, 10, 10, 3, 5, "uint8"); | 202 %! rgb = randi (255, 10, 10, 3, 5, "uint8"); |
203 %! alpha = randi (255, 10, 10, 1, 5, "uint8"); | 203 %! alpha = randi (255, 10, 10, 1, 5, "uint8"); |
204 %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); | 204 %! [r, ~, a] = write_and_read (".tif", rgb, "Alpha", alpha); |
205 %! assert (r, rgb); | 205 %! assert (r, cat (3, rgb, alpha)); |
206 %! assert (a, alpha); | 206 %! assert (a, []); |
207 | 207 |
208 %!testif HAVE_MAGICK | 208 %!testif HAVE_MAGICK |
209 %! gray = repmat (uint8 (0:255), 100, 1); | 209 %! gray = repmat (uint8 (0:255), 100, 1); |
210 %! [g] = write_and_read (".jpeg", gray); | 210 %! [g] = write_and_read (".jpeg", gray); |
211 %! assert (g, gray, 2); | 211 %! assert (g, gray, 2); |