-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.java
More file actions
29 lines (26 loc) · 801 Bytes
/
Copy pathUtility.java
File metadata and controls
29 lines (26 loc) · 801 Bytes
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
package app;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;
public class Utility {
/**
* Converts a color image into shades of grey.
* @param input The image on which to perform the desaturate.
* @param output The image in which to store the output.
*/
static public void desaturate(Mat input, Mat output) {
switch (input.channels()) {
case 1:
// If the input is already one channel, it's already desaturated
input.copyTo(output);
break;
case 3:
Imgproc.cvtColor(input, output, Imgproc.COLOR_BGR2GRAY);
break;
case 4:
Imgproc.cvtColor(input, output, Imgproc.COLOR_BGRA2GRAY);
break;
default:
throw new IllegalArgumentException("Input to desaturate must have 1, 3, or 4 channels");
}
}
}