I am trying to fill color to that square objects. It does not look like a perfect square. I have attached 4 sample images. Please have a look at it. Please help me with your ideas.
By using this code I can change the background and line colors. But I want to fill color that unshaped squares (squares only not triangle).
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
String img_url1 = "C:\\\\Users\\\\me\\\\Desktop\\\\cpt\\\\1.png";
Mat img = Imgcodecs.imread(img_url1, -1);
List<Mat> channels = new ArrayList<>();
Core.split(img, channels);
Mat black = new Mat();
Core.bitwise_not(channels.get(3), black);
String file2 = "C:\\\\\\\\Users\\\\\\\\me\\\\\\\\Desktop\\\\\\\\cpt\\\\\\\\1-cpy.png";
Imgcodecs.imwrite(file2, black);
Input Images :