Example usage for org.opencv.core Point Point

List of usage examples for org.opencv.core Point Point

Introduction

In this page you can find the example usage for org.opencv.core Point Point.

Prototype

public Point(double x, double y) 

Source Link

Usage

From source file:com.ttolley.pongbot.opencv.CvWorker.java

private Target findTarget(List<MatOfPoint> contours, Mat webcam_image, Filter filter) {
    Target largestTarget = null;//from w w  w  .jav a 2s. c  om
    for (MatOfPoint matOfPoint : contours) {
        Moments moment = Imgproc.moments(matOfPoint);
        double area = moment.get_m00();

        if ((largestTarget == null && area > filter.objectSize * filter.objectSize)
                || (largestTarget != null && area > largestTarget.area)) {
            // Found object, do something about it
            largestTarget = new Target(moment.get_m10() / area, moment.get_m01() / area, area);
        }
    }
    if (largestTarget != null) {
        xPos.addValue(largestTarget.x);
        yPos.addValue(largestTarget.y);
        Core.circle(webcam_image, new Point(xPos.getMean(), yPos.getMean()), 10, new Scalar(0, 0, 255));
        Core.putText(webcam_image, "[" + xPos.getMean() + " " + yPos.getMean() + "]",
                new Point(xPos.getMean() - 40, yPos.getMean() + 25), 1, 1, new Scalar(0, 0, 255));
    }
    return largestTarget;
}

From source file:com.wallerlab.compcellscope.calcDPCTask.java

License:BSD License

protected Long doInBackground(Mat... matrix_list) {
    //int count = urls.length;
    Mat in1 = matrix_list[0];/* ww  w. j  a v  a  2s.c om*/
    Mat in2 = matrix_list[1];
    Mat outputMat = matrix_list[2];

    Mat Mat1 = new Mat(in1.width(), in1.height(), in1.type());
    Mat Mat2 = new Mat(in2.width(), in2.height(), in2.type());
    in1.copyTo(Mat1);
    in2.copyTo(Mat2);

    Imgproc.cvtColor(Mat1, Mat1, Imgproc.COLOR_RGBA2GRAY, 1);
    Imgproc.cvtColor(Mat2, Mat2, Imgproc.COLOR_RGBA2GRAY, 1);

    Mat output = new Mat(Mat1.width(), Mat1.height(), CvType.CV_8UC4);
    Mat dpcSum = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);
    Mat dpcDifference = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);
    Mat dpcImgF = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);

    /*
    Log.d(TAG,String.format("Mat1 format is %.1f-%.1f, type: %d",Mat1.size().width,Mat1.size().height,Mat1.type()));
    Log.d(TAG,String.format("Mat2 format is %.1f-%.1f, type: %d",Mat2.size().width,Mat2.size().height,Mat2.type()));
    */

    // Convert to Floats
    Mat1.convertTo(Mat1, CvType.CV_32FC1);
    Mat2.convertTo(Mat2, CvType.CV_32FC1);
    Core.add(Mat1, Mat2, dpcSum);
    Core.subtract(Mat1, Mat2, dpcDifference);
    Core.divide(dpcDifference, dpcSum, dpcImgF);
    Core.add(dpcImgF, new Scalar(1.0), dpcImgF); // Normalize to 0-2.0
    Core.multiply(dpcImgF, new Scalar(110), dpcImgF); // Normalize to 0-255
    dpcImgF.convertTo(output, CvType.CV_8UC1); // Convert back into RGB
    Imgproc.cvtColor(output, output, Imgproc.COLOR_GRAY2RGBA, 4);

    dpcSum.release();
    dpcDifference.release();
    dpcImgF.release();
    Mat1.release();
    Mat2.release();

    Mat maskedImg = Mat.zeros(output.rows(), output.cols(), CvType.CV_8UC4);
    int radius = maskedImg.width() / 2 + 25;
    Core.circle(maskedImg, new Point(maskedImg.width() / 2, maskedImg.height() / 2), radius,
            new Scalar(255, 255, 255), -1, 8, 0);
    output.copyTo(outputMat, maskedImg);
    output.release();
    maskedImg.release();
    return null;
}

From source file:com.wallerlab.compcellscope.MultiModeViewActivity.java

License:BSD License

public Mat calcDPC(Mat in1, Mat in2, Mat out) {
    Mat Mat1 = new Mat(in1.width(), in1.height(), in1.type());
    Mat Mat2 = new Mat(in2.width(), in2.height(), in2.type());
    in1.copyTo(Mat1);//w  w  w.  j a  v  a2s . c  o  m
    in2.copyTo(Mat2);

    Imgproc.cvtColor(Mat1, Mat1, Imgproc.COLOR_RGBA2GRAY, 1);
    Imgproc.cvtColor(Mat2, Mat2, Imgproc.COLOR_RGBA2GRAY, 1);

    Mat output = new Mat(Mat1.width(), Mat1.height(), CvType.CV_8UC4);
    Mat dpcSum = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);
    Mat dpcDifference = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);
    Mat dpcImgF = new Mat(Mat1.width(), Mat1.height(), CvType.CV_32FC1);

    /*
    Log.d(TAG,String.format("Mat1 format is %.1f-%.1f, type: %d",Mat1.size().width,Mat1.size().height,Mat1.type()));
    Log.d(TAG,String.format("Mat2 format is %.1f-%.1f, type: %d",Mat2.size().width,Mat2.size().height,Mat2.type()));
    */

    // Convert to Floats
    Mat1.convertTo(Mat1, CvType.CV_32FC1);
    Mat2.convertTo(Mat2, CvType.CV_32FC1);
    Core.add(Mat1, Mat2, dpcSum);
    Core.subtract(Mat1, Mat2, dpcDifference);
    Core.divide(dpcDifference, dpcSum, dpcImgF);
    Core.add(dpcImgF, new Scalar(1.0), dpcImgF); // Normalize to 0-2.0
    Core.multiply(dpcImgF, new Scalar(110), dpcImgF); // Normalize to 0-255
    dpcImgF.convertTo(output, CvType.CV_8UC1); // Convert back into RGB
    Imgproc.cvtColor(output, output, Imgproc.COLOR_GRAY2RGBA, 4);

    dpcSum.release();
    dpcDifference.release();
    dpcImgF.release();
    Mat1.release();
    Mat2.release();

    Mat maskedImg = Mat.zeros(output.rows(), output.cols(), CvType.CV_8UC4);
    int radius = maskedImg.width() / 2 + 25;
    Core.circle(maskedImg, new Point(maskedImg.width() / 2, maskedImg.height() / 2), radius,
            new Scalar(255, 255, 255), -1, 8, 0);
    output.copyTo(out, maskedImg);
    output.release();
    maskedImg.release();
    return out;
}

From source file:com.wallerlab.compcellscope.MultiModeViewActivity.java

License:BSD License

public Mat generateMMFrame(Mat gridOut, Mat MatTL, Mat MatTR, Mat MatBL, Mat MatBR) {
    //gridOut = new Mat(100, 100, gridOut.type(), new Scalar(0,0,0));
    Mat Mat1 = new Mat(MatTL.size(), MatTL.type());
    Mat Mat2 = new Mat(MatTR.size(), MatTR.type());
    Mat Mat3 = new Mat(MatBL.size(), MatBL.type());
    Mat Mat4 = new Mat(MatBR.size(), MatBR.type());

    // Ensure all of the mats are of the correct size since pyramid operation resizes
    Imgproc.resize(MatTL, MatTL, sz);//from   w  w  w.ja  v a2 s . c  om
    Imgproc.resize(MatTR, MatTR, sz);
    Imgproc.resize(MatBL, MatBL, sz);
    Imgproc.resize(MatBR, MatBR, sz);

    // Downsample by 2 for 2x2 grid
    Imgproc.pyrDown(MatBL, Mat1);
    Imgproc.pyrDown(MatBR, Mat2);
    Imgproc.pyrDown(MatTL, Mat3);
    Imgproc.pyrDown(MatTR, Mat4);

    /*
    Log.d(TAG,String.format("TLRect format is %.1f-%.1f",TLRect.size().width,TLRect.size().height));
    Log.d(TAG,String.format("TRRect format is %.1f-%.1f",TRRect.size().width,TRRect.size().height));
            
    Log.d(TAG,String.format("BLRect format is %.1f-%.1f",BLRect.size().width,BLRect.size().height));
    Log.d(TAG,String.format("BRRect format is %.1f-%.1f",BRRect.size().width,BRRect.size().height));
            
    Log.d(TAG,String.format("MatTL format is %.1f-%.1f",MatTL.size().width,MatTL.size().height));
    Log.d(TAG,String.format("MatTR format is %.1f-%.1f",MatTR.size().width,MatTR.size().height));
            
    Log.d(TAG,String.format("MatBL format is %.1f-%.1f",MatBL.size().width,MatBL.size().height));
    Log.d(TAG,String.format("MatBR format is %.1f-%.1f",MatBR.size().width,MatBR.size().height));
     */

    Core.putText(Mat1, "DPC-LR", new Point(43, 40), Core.FONT_ITALIC, 1, new Scalar(255, 255, 0));
    Core.putText(Mat2, "DPC-TB", new Point(43, 40), Core.FONT_ITALIC, 1, new Scalar(255, 255, 0));
    Core.putText(Mat3, "BrightField", new Point(33, 40), Core.FONT_ITALIC, 1, new Scalar(255, 255, 0));
    Core.putText(Mat4, "DarkField", new Point(37, 40), Core.FONT_ITALIC, 1, new Scalar(255, 255, 0));

    Mat1.copyTo(gridOut.submat(BLRect));
    Mat2.copyTo(gridOut.submat(BRRect));
    Mat3.copyTo(gridOut.submat(TLRect));
    Mat4.copyTo(gridOut.submat(TRRect));

    Mat1.release();
    Mat2.release();
    Mat3.release();
    Mat4.release();

    return gridOut;
}

From source file:Comun.Imagen.java

public String dividirImagen(String nombreCarpeta) {
    StringBuilder SB = new StringBuilder();

    //Crea la carpeta donde alojar las imagenes
    this.nombreCarpeta = nombreCarpeta;
    File carpeta = new File(nombreCarpeta);
    if (carpeta.mkdir()) {
        Mat imgAux = new Mat();
        //Convertir la imagen en escala de grises a binario
        threshold(imagen, imgAux, 128, 255, THRESH_BINARY | THRESH_OTSU);

        //Dibuja los bordes
        double umbral = 100;
        Canny(imgAux, imgAux, umbral, umbral * 2);

        //Lista que guarda los puntos de los contornos
        LinkedList<MatOfPoint> contornos = new LinkedList<>();
        Mat jerarquia = new Mat();

        //Detecto los contornos
        findContours(imgAux, contornos, jerarquia, RETR_TREE, CHAIN_APPROX_SIMPLE);

        Rect contorno;/*from w  w w . j a  v a  2 s  . co m*/

        if (!contornos.isEmpty()) {
            SB.append("Se han encontrado ").append(contornos.size()).append(" contornos -");

            double areaProm = 0;
            for (int i = 0; i < contornos.size(); i++) {
                contorno = boundingRect(contornos.get(i));
                areaProm += contorno.area();
            }

            //Asigna que para ser un contorno valido debe ser mayor al 10% del segundo mayor
            areaProm = (areaProm / contornos.size()) * 0.25;
            ArrayList<Rect> contornosFiltrados = new ArrayList<>();

            //Guarda las letras detectadas
            for (int i = 0; i < contornos.size(); i++) {

                contorno = boundingRect(contornos.get(i));
                //Verifica que supere el limite
                if (contorno.area() > areaProm) {
                    contornosFiltrados.add(contorno);
                }
            }
            //Ordeno los contornos de mayor a menor
            Mergesort merge = new Mergesort(contornosFiltrados);
            merge.ordenar();
            contornosFiltrados = merge.getV();

            //Filtro solo los contornos que no se superponen con otro
            ArrayList<Rect> contornosFinal = new ArrayList<>();
            boolean bandera = false;
            for (Rect recta : contornosFiltrados) {
                for (Rect c : contornosFinal) {
                    if (c.contains(recta.tl()) || c.contains(recta.br())) {
                        bandera = true;
                        break;
                    }
                }
                if (!bandera) {
                    //Agrego el contorno a la lista final de contornos
                    contornosFinal.add(recta);
                    //Guardo la imagen en la carpeta
                    this.guardarImagen(new Mat(imagen, recta), contornosFinal.size());

                    //La marca en la imagen principal
                    rectangle(imagen, new Point(recta.x, recta.y),
                            new Point(recta.x + recta.width, recta.y + recta.height), new Scalar(0, 255, 0));
                }
                bandera = false;
            }

            SB.append("Contornos Validos: ").append(contornosFinal.size());

        } else {
            SB.append("No se ha encontrado ningun contorno");
        }
    } else {
        SB.append("No se pudo crear la carpeta");
    }
    this.guardarImagen(imagen, 0);
    return SB.toString();
}

From source file:contador_de_moedas.Circulo.java

private Mat doCirciloHough(Mat imgIn) {
    int valor = 0;
    baseImageList();//from w w  w.j  a  va 2s.c o m
    Reconhecimento _reco;
    Imgproc.cvtColor(imgIn, imgIn, Imgproc.COLOR_BGR2GRAY);
    /*Imgproc.erode(imgIn, imgIn, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2, 2)));
     Imgproc.dilate(imgIn, imgIn, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2, 2)));*/

    double min_dist_Centro = imgIn.rows() / 8.0;
    /*
     Imgproc.HoughCircles(imageB, circles, method, dp, minDist, param1, param2, minRadius, maxRadius)
     imageB: Imagem de entrada (tons de cinza)
     circles: um vector que armazena conjuntos de 3 valores: Xc, Yc, r para cada crculo detectado.
     method: CV_HOUGH_GRADIENT definir o mtodo de deteco. Atualmente, esse  o nico disponvel em OpenCV
     dp: (1) A razo inversa da resoluo
     min_dist: (imgIn.rows / 8 ) A distncia mnima entre centros detectados
     param1: (200 limite superior para o detector de bordas Canny interna) limite superior para o detector de bordas Canny interna
     param2: (100* Limiar para deteco de centro)Limiar para deteco de centro.
     minRadius: (0) raio minimo a ser detectado. Se for desconhecida, colocar zero como padrao.
     maxRadius: (maxRadius) raio maximo a ser detectado. Se desconhecida, colocar zero como padrao   
     */
    Imgproc.HoughCircles(imgIn, circles, Imgproc.CV_HOUGH_GRADIENT, 1, min_dist_Centro, param1, param2,
            minRadius, maxRadius);

    rowsCols[0] = circles.rows();
    rowsCols[1] = circles.cols();

    for (int i = 0; i < circles.cols(); i++) {
        _reco = new Reconhecimento();
        double data[] = circles.get(0, i);
        Point pt = new Point(Math.round(data[0]), Math.round(data[1]));
        int raio = (int) Math.round(data[2]);

        if (data[2] > 20.0 && data[2] < 28.0) {
            valor = 10;
            setSomatorio(getSomatorio() + valor);
        } else if (data[2] > 27.0 && data[2] < 32.0) {
            valor = 5;
            setSomatorio(getSomatorio() + valor);
        } else if (data[2] > 32.0 && data[2] < 33.0) {
            valor = 50;
            setSomatorio(getSomatorio() + valor);
        } else if (data[2] > 33.5 && data[2] < 36.0) {
            valor = 25;
            setSomatorio(getSomatorio() + valor);
        } else if (data[2] > 35.0 && data[2] < 40.0) {
            valor = 100;
            setSomatorio(getSomatorio() + valor);
        }
        resultados.add(" r:" + (int) raio + "   (X:" + (int) pt.x + "-Y:" + (int) pt.y + ") Val: " + valor);
        vetMat[i] = _reco.CriaMascara(pt, data[2], imgIn);
        output = _reco.CalculaHistograma(vetMat[i], imageA);

        /*  System.out.println("histogram\n"+output.dump());
         for (int j = 0; j < vetMatFile.length - 1; j++) {
         Mat ab = vetMatFile[j];
         System.out.println("histogram\n"+vetMatFile[j].dump());
         double distance = Imgproc.compareHist(output, vetMatFile[j], Imgproc.CV_COMP_CORREL);
                
         System.out.print("ok");
         }*/

        if (criaBase) {
            FileWriter arq = null;
            try {
                String nome = "X" + (int) pt.x + "Y" + (int) pt.y + "R" + (int) raio;
                // Imgcodecs.imwrite("baseConhecimento/" + nome + "M.png", vetMat[i]);
                arq = new FileWriter("baseConhecimento/" + nome + ".txt");
                PrintWriter gravarArq = new PrintWriter(arq);
                gravarArq.print(output.dump());
                arq.close();
                // Imgcodecs.imwrite("baseConhecimento/" + nome + ".yml", output);
            } catch (IOException ex) {
                Logger.getLogger(Circulo.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    arq.close();
                } catch (IOException ex) {
                    Logger.getLogger(Circulo.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

        Imgproc.circle(imageA, pt, raio, new Scalar(0, 0, 255), 2);
        Imgproc.circle(imageA, pt, 2, new Scalar(0, 255, 0), 1);
    }
    return imageA;
}

From source file:cubesolversimulator.VisualInputForm.java

private void findRect(List<MatOfPoint> contours) {
    int j = 0;//from w w  w.  j  a v  a  2  s. c  om
    temp = blured.clone();
    List<Rect> roi = new ArrayList<>();
    for (int i = 0; i < contours.size(); i++) {
        Rect rect = Imgproc.boundingRect(contours.get(i));
        if (rect.height > 60 && rect.width > 60 && rect.height < 140 && rect.width < 140
                && (rect.height <= (rect.width + 30) || rect.height >= (rect.width - 30))) {
            Core.rectangle(temp, new Point(rect.x, rect.y),
                    new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0), 2);
            j++;
            roi.add(rect);
            // System.out.println(rect.x+"   "+rect.y);
        }
    }
    Highgui.imwrite("rect.jpg", temp);
    //System.out.println(j+" "+roi.size());
    filterOverlap(roi);
}

From source file:cubesolversimulator.VisualInputForm.java

private void filterOverlap(List<Rect> roi) {
    Mat filtered = blured.clone();/*from ww  w.  ja  v a2 s  .c  o  m*/
    for (int i = 0; i < roi.size(); i++) {
        for (int j = i + 1; j < roi.size(); j++) {
            if ((roi.get(i).x >= roi.get(j).x - 100 && roi.get(i).x <= roi.get(j).x + 100)
                    && (roi.get(i).y >= roi.get(j).y - 100 && roi.get(i).y <= roi.get(j).y + 100)) {
                if (roi.get(i).area() > roi.get(j).area()) {
                    roi.remove(i);
                } else {
                    roi.remove(j);
                }
            }
        }
    }
    //System.out.println("Final Size: "+roi.size());
    for (int i = 0; i < roi.size(); i++) {
        // System.out.println()
        Rect rect = roi.get(i);
        Core.rectangle(filtered, new Point(rect.x, rect.y),
                new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 255), 2);
    }
    Highgui.imwrite("filteredrect.jpg", filtered);

    img5 = new JLabel("");
    img5.setSize(jPanel2.getSize());
    image5 = new ImageIcon(new ImageIcon("D:\\Project_work\\CubeSolverSimulator\\filteredrect.jpg").getImage()
            .getScaledInstance(img5.getWidth(), img5.getHeight(), Image.SCALE_FAST));
    img5.setIcon(image5);
    img5.repaint();
    jPanel2.add(img5);
    jPanel2.repaint();

    reorderContours(roi);
    findAvg(roi);
}

From source file:cx.uni.jk.mms.iaip.brush.BrushModel.java

License:Open Source License

private void updateAlphaMat() {
    this.alphaMat = Mat.zeros(this.size, this.size, MatModel.MAT_TYPE);
    switch (this.shape) {
    case SQUARE://from   w  ww.ja  v  a 2s.co m
        Core.add(this.alphaMat, new Scalar(1.0f), this.alphaMat);
        break;
    case CIRCLE:
        Core.circle(this.alphaMat, new Point((this.size - 1) * 0.5d, (this.size - 1) * 0.5d),
                (this.size - 1) / 2, new Scalar(1.0f), -1);
        break;
    case SOFT_CIRCLE: {
        Mat temp = this.alphaMat.clone();
        Core.circle(temp, new Point((this.size - 1) * 0.5d, (this.size - 1) * 0.5d), (this.size - 1) / 4,
                new Scalar(1.0f), -1);
        Imgproc.blur(temp, this.alphaMat, new Size(this.size * 0.5d, this.size * 0.5d));
    }
        break;
    default:
        /** this must not happen, die */
        throw new RuntimeException("unexpected BrushModel.Shape = " + this.shape);
    }
}

From source file:cx.uni.jk.mms.iaip.tools.SimpleBrushTool.java

License:Open Source License

@Override
public Rect apply(Mat mat, BrushModel brush, int x, int y, boolean inverseEffect) {

    Rect changedArea = null;//w  w  w  .  j ava 2 s .c  o  m

    try {
        this.logger.finer(String.format("apply mode=\"%s\" inverse=%s, size=%d, strength=%d", brush.getMode(),
                inverseEffect, brush.getSize(), brush.getValue()));

        this.logger.finest("mat    = " + mat.toString());

        /** where is brush going to work? this may reach outside the mat! */
        int brushColStart = x - (brush.getSize() - 1) / 2;
        int brushColEnd = x + brush.getSize() / 2;
        int brushRowStart = y - (brush.getSize() - 1) / 2;
        int brushRowEnd = y + brush.getSize() / 2;

        if (brushColEnd >= 0 && brushColStart < mat.cols() && brushRowEnd >= 0 && brushRowStart < mat.rows()) {

            /** calculate bounds for roiMat to fit into original mat */
            int subColStart = Math.max(0, brushColStart);
            int subColEnd = Math.min(brushColEnd, mat.cols() - 1);
            int subRowStart = Math.max(0, brushRowStart);
            int subRowEnd = Math.min(brushRowEnd, mat.rows() - 1);

            /**
             * the caller may want to know. Rect constructor interprets the
             * second point being outside of the Rect! a one pixel rectangle
             * Rect(Point(a,b), Point(a+1,b+1)) has height and width 1. see
             * 
             * @link{http://docs.opencv.org/java/org/opencv/core/Rect.html
             */
            changedArea = new Rect(new Point(subColStart, subRowStart),
                    new Point(subColEnd + 1, subRowEnd + 1));

            /**
             * get the part of original mat which going to be affected by
             * change
             */
            Mat roiMat = mat.submat(subRowStart, subRowEnd + 1, subColStart, subColEnd + 1);
            this.logger.finest("matRoi = " + roiMat.toString());

            /** does the brush fit into the roiMat we shall work on ? */
            boolean brushFits = brushColStart == subColStart && brushColEnd == subColEnd
                    && brushRowStart == subRowStart && brushRowEnd == subRowEnd;

            this.logger.finest("brush fits = " + brushFits);

            /**
             * make sure to have a working mat which matches the full brush
             * size
             */
            Mat workMat, workRoi = null;
            if (brushFits) {
                /** just work in the original mat area defined by roi */
                workMat = roiMat;
            } else {
                /** create a new mat as big as the brush */
                workMat = Mat.zeros(brush.getSize(), brush.getSize(), MatModel.MAT_TYPE);
                this.logger.finest("workMat= " + workMat.toString());
                /**
                 * create an ROI in the workMat as big as the subMat,
                 * correct offset for brushing in the middle
                 */
                int roiColStart = subColStart - brushColStart;
                int roiColEnd = roiColStart + roiMat.cols();
                int roiRowStart = subRowStart - brushRowStart;
                int roiRowEend = roiRowStart + roiMat.rows();

                workRoi = workMat.submat(roiRowStart, roiRowEend, roiColStart, roiColEnd);
                this.logger.finest("workRoi= " + workRoi.toString());
                roiMat.copyTo(workRoi);
                this.logger.finest("workRoi= " + workRoi.toString());

                // workRoi.put(0, 0, 1333.0d);
                this.logger.finest("roiMat  dump1 " + roiMat.dump());
                this.logger.finest("workRoi dump1 " + workRoi.dump());
                this.logger.finest("workMat dump1 " + workMat.dump());
            }

            /** the real action */
            this.applyToWorkMat(brush, inverseEffect, workMat);

            this.logger.finest("workMat dump2 " + workMat.dump());
            this.logger.finest("matRoi  dump2 " + roiMat.dump());

            if (brushFits) {
                /**
                 * nothing to do, we have been working directly in original
                 * mat
                 */
            } else {
                /** copy workMat back into original mat */
                this.logger.finest("workRoi dump2 " + workRoi.dump());
                // workRoi.put(0, 0, 1338);
                this.logger.finest("workRoi dump3 " + workRoi.dump());
                /**
                 * copy roi of changed workmat back into roi of original mat
                 */
                this.logger.finest("matRoi = " + roiMat.toString());
                workRoi.copyTo(roiMat);
                this.logger.finest("matRoi = " + roiMat.toString());
            }
            this.logger.finest("matRoi  dump3 " + roiMat.dump());
        }

    } catch (CvException e) {
        /** nevermind if the user does not notice */
        this.logger.fine(e.getStackTrace().toString());
    }

    /** let the caller know caller which area has potentially been changed */
    return changedArea;
}