keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

Set matrix center correctly #314

Closed eli-osherovich closed 3 years ago

eli-osherovich commented 3 years ago

Matrix center was set incorrectly (one off). To correct either call transform_matrix_offset_center() with h-1 ,w-1. Or fix the sign inside that function and continue using h and w (more intuitive).

Summary

Related Issues

PR Overview

Dref360 commented 3 years ago

Could we add a test to be sure that the matrix is rightly centered?

eli-osherovich commented 3 years ago

@Dref360 Do you mean a unit test or the way to know wether + or - is correct?

Here is a simple example:

img = np.expand_dims(np.array([[0, 1], [0, 0]]), -1)
tf.keras.preprocessing.image.apply_affine_transform(img, theta=90)

array([[[0],
        [0]],

       [[0],
        [0]]])
Dref360 commented 3 years ago

Yes so that if we modify this portion of the code again, we won't merge the same bug.

eli-osherovich commented 3 years ago

Added a unit test.

P. S. There are two existing tests that seem to fail. These should be fixed in a separate PR.