Floodfill не работает, также Mat.get (столбец, строка) возвращает неправильный цвет - PullRequest
0 голосов
/ 03 октября 2018

заливка не влияет на растровое изображение, а Mat.get (столбец, строка) возвращает неправильный цвет.

Что я сделал: a) проверил, что растровое изображение и матрица имеют одинаковый размер.2) проверил цвет оба способа RGB и BGR.3) проверил начальный bmp и конечный bmp (после применения заливки).4) проверено заполнение обеих подписей

public void flood(int x,int y,int sourceColor,int newColor){
    try {
        Bitmap bmp;
        if(OpenCVLoader.initDebug()){
            image = new Mat();
            mat1 = new Mat();
            Utils.bitmapToMat(bmp2,mat1);
            image = Mat.zeros(mat1.rows()+2,mat1.cols()+2,CvType.CV_8U);
            if(bmp2.getWidth()==mat1.cols()){}
        }
        int k = mat1.channels();
        int col = bmp2.getPixel(x, y);
        int alpha = col & 0xFF000000;
        int red = (col & 0x00FF0000) >> 16;
        int green = (col & 0x0000FF00) >> 8;
        int blue = (col & 0x000000FF);
        double[] tt = (mat1.get(x,y));
        Imgproc.cvtColor(mat1,mat1,Imgproc.COLOR_BGRA2BGR);
        tt = (mat1.get(x,y));

        //Imgproc.floodFill(mat1,image,p1,new Scalar(blue,green,red),new Rect(),new Scalar(230),new Scalar(220),4 + (255<<8) + Imgproc.FLOODFILL_MASK_ONLY);
        Imgproc.floodFill(mat1,image,p1,new Scalar(255,255,255));
        Core.subtract(image, Scalar.all(0), image);
        Rect roi = new Rect(1, 1, mat1.cols() - 2, mat1.rows() - 2);
        Mat temp = new Mat();

        image.submat(roi).copyTo(temp);
        mat1 = temp;
        bmp = Bitmap.createBitmap(mat1.cols(),mat1.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(mat1,bmp);
                }catch(CvException ex){
        System.out.println(ex.getMessage());
        ex.getLocalizedMessage();
    }
}

Любая помощь будет оценена.Заранее спасибо.

...