Sunday, June 9, 2013

Converting Image to Gray Scale

// Load the image from directory
Mat image = Highgui.imread("C:path/to/input/image.tif");
// Convert image to gray scale
System.out.println("Converting input image to gray scale");
Mat grayImage = new Mat();
Imgproc.cvtColor(image, grayImage, Imgproc.COLOR_BGR2GRAY);
// Save the transformed image
String filename = "resultImage.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, grayImage);
view raw mizuki hosted with ❤ by GitHub

No comments:

Post a Comment