### Question:
ROI { public ROI(String name,double rx, double ry, double rw, double rh) { this.name=name; this.rx = rx; this.ry = ry; this.rw = rw; this.rh = rh; } ROI(String name,double rx, double ry, double rw, double rh); Rect roiRect(Size base); Mat region(Mat image); String toString();  }### Answer:
@Test public void testROI() throws Exception { if (!isTravis()) { NativeLibrary.load(); File imgRoot = new File(testPath); assertTrue(imgRoot.isDirectory()); Mat image = Imgcodecs.imread(testPath + "dukes_roi_test_image.jpg"); assertNotNull(image); assertEquals(960, image.height()); assertEquals(1280, image.width()); ROI rois[] = { new ROI("all", 0, 0, 1, 1), new ROI("far", 0, 0, 1, 0.5), new ROI("near", 0, 0.5, 1, 0.5), new ROI("left", 0, 0, 0.5, 1), new ROI("right", 0.5, 0, 0.5, 1) }; for (ROI roi : rois) { System.out.println(roi); Mat roiImage = roi.region(image); if (debug) System.out.println(String.format("%10s: %4d x %4d", roi.name, roiImage.width(), roiImage.height())); assertEquals(roiImage.width(), image.width() * roi.rw, 0.1); assertEquals(roiImage.height(), image.height() * roi.rh, 0.1); this.writeImage("dukes_roi_" + roi.name, roiImage); } } }