Skip to content

Commit 7375fcf

Browse files
committed
cast sharpen image to int16
We were assuming that if the input image was already labs, it was int16 labs. Thanks @CoachRDeveloper. See #4147
1 parent 12cf4bd commit 7375fcf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libvips/convolution/sharpen.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ vips_sharpen_build(VipsObject *object)
199199
in = t[0];
200200

201201
if (vips_check_uncoded(class->nickname, in) ||
202-
vips_check_bands_atleast(class->nickname, in, 3) ||
203-
vips_check_format(class->nickname, in, VIPS_FORMAT_SHORT))
202+
vips_check_bands_atleast(class->nickname, in, 3))
204203
return -1;
205204

206205
/* Stop at 10% of max ... a bit mean. We always sharpen a short,
@@ -217,6 +216,12 @@ vips_sharpen_build(VipsObject *object)
217216
vips_matrixprint(t[1], NULL);
218217
#endif /*DEBUG*/
219218

219+
/* Make sure we're short (need this for the LUT) and not eg. float LABS.
220+
*/
221+
if (vips_cast_short(in, &t[2], NULL))
222+
return -1;
223+
in = t[2];
224+
220225
/* Index with the signed difference between two 0 - 32767 images.
221226
*/
222227
if (!(sharpen->lut = VIPS_ARRAY(object, 65536, int)))

0 commit comments

Comments
 (0)