@Test
public void testCenterCropIfNeeded() throws Exception {

    int w1 = 60, h1 = 110, ch1 = 1;
    int w2 = 120, h2 = 70, ch2 = 3;
    Mat img1 = makeRandomImage(h1, w1, ch1);
    Mat img2 = makeRandomImage(h2, w2, ch2);
    NativeImageLoader loader = new NativeImageLoader(h1, w1, ch1, true);
    Mat cropped1 = loader.centerCropIfNeeded(img1);
    assertEquals(85, cropped1.rows());
    assertEquals(60, cropped1.cols());
    assertEquals(img1.channels(), cropped1.channels());
    Mat cropped2 = loader.centerCropIfNeeded(img2);
    assertEquals(70, cropped2.rows());
    assertEquals(95, cropped2.cols());
    assertEquals(img2.channels(), cropped2.channels());
}