Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
37 lines (28 loc) · 1.19 KB

File metadata and controls

37 lines (28 loc) · 1.19 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package dip;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import origami.Origami;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import java.io.IOException;
public class ImageShapeConversions {
public static void main(String[] args) throws IOException {
Origami.init();
File input = new File("data/dip/digital_image_processing.jpg");
BufferedImage image = ImageIO.read(input);
byte[] data = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
Mat mat = new Mat(image.getHeight(), image.getWidth(), CvType.CV_8UC3);
mat.put(0, 0, data);
Mat mat1 = new Mat(image.getHeight(), image.getWidth(), CvType.CV_8UC3);
Core.flip(mat, mat1, -1);
byte[] data1 = new byte[mat1.rows() * mat1.cols() * (int) (mat1.elemSize())];
mat1.get(0, 0, data1);
BufferedImage image1 = new BufferedImage(mat1.cols(), mat1.rows(), 5);
image1.getRaster().setDataElements(0, 0, mat1.cols(), mat1.rows(), data1);
File outout = new File("hsv.jpg");
ImageIO.write(image1, "jpg", outout);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.