Imgcodecs.imwrite("C:\\File\\input.jpg", img) Mat img = new Mat(image.getHeight(),image.getWidth(), CvType.CV_8UC3) ImageCopy.getGraphics().drawImage(image, 0, 0, null) īyte data = ((DataBufferByte) imageCopy.getRaster().getDataBuffer()).getData() New BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_3BYTE_BGR) Here we convert into *supported* format
This is for the approach with conversion: File input = new File("C:\\File\\1.tif") īufferedImage image = ImageIO.read(input) You can also use different supported Mat image type instead of CvType.CV_8UC3,īut that depends if there are equivalent types for java ones. You can create an new BufferedImage of same size with type 3BYTE_BGR, and then draw the original image into it, then you can construct a Mat from this new one. It is all because the data type of the different images differ.įor one you have DataBufferByte, for other you may have DataBufferInt.