List of usage examples for org.opencv.core Core copyMakeBorder
public static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType, Scalar value)
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.util.ResultUtil.java
License:Open Source License
@NonNull public static Mat createStripMat(@NonNull Mat mat, @NonNull Point centerPatch, boolean grouped, int maxWidth) { //done with lab schema, make rgb to show in image view // mat holds the strip image Imgproc.cvtColor(mat, mat, Imgproc.COLOR_Lab2RGB); int rightBorder = 0; double ratio; if (mat.width() < MIN_STRIP_WIDTH) { ratio = MAX_STRIP_HEIGHT / mat.height(); rightBorder = BORDER_SIZE;//from w w w. ja v a 2 s.c o m } else { ratio = (double) (maxWidth - 10) / (double) mat.width(); } Imgproc.resize(mat, mat, new Size(mat.width() * ratio, mat.height() * ratio)); Core.copyMakeBorder(mat, mat, BORDER_SIZE + ARROW_TRIANGLE_HEIGHT, BORDER_SIZE * 2, 0, rightBorder, Core.BORDER_CONSTANT, new Scalar(MAX_RGB_INT_VALUE, MAX_RGB_INT_VALUE, MAX_RGB_INT_VALUE, MAX_RGB_INT_VALUE)); // Draw an arrow to the patch // only draw if this is not a 'grouped' strip if (!grouped) { double x = centerPatch.x * ratio; double y = 0; MatOfPoint matOfPoint = new MatOfPoint(new Point((x - ARROW_TRIANGLE_LENGTH), y), new Point((x + ARROW_TRIANGLE_LENGTH), y), new Point(x, y + ARROW_TRIANGLE_HEIGHT), new Point((x - ARROW_TRIANGLE_LENGTH), y)); Imgproc.fillConvexPoly(mat, matOfPoint, DARK_GRAY, Core.LINE_AA, 0); } return mat; }