blob: 73b435b1e278008a242bc079d406fee066435ec1 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/**
* @author Pacien TRAN-GIRARD
* @author Timothée FLOURE
*/
public final class Filter {
/**
* Get a pixel without accessing out of bounds
*
* @param gray a HxW float array
* @param row Y coordinate
* @param col X coordinate
* @return nearest valid pixel color
*/
public static float at(float[][] gray, int row, int col) {
int maxRow = gray.length - 1;
int maxCol = gray[0].length - 1;
if (row < 0) row = 0;
if (col < 0) col = 0;
if (row > maxRow) row = maxRow;
if (col > maxCol) col = maxCol;
return gray[row][col];
}
/**
* Convolve a single-channel image with specified kernel.
*
* @param gray a HxW float array
* @param kernel a MxN float array, with M and N odd
* @return a HxW float array
*/
public static float[][] filter(float[][] gray, float[][] kernel) {
// TODO filter
return null;
}
/**
* Smooth a single-channel image
*
* @param gray a HxW float array
* @return a HxW float array
*/
public static float[][] smooth(float[][] gray) {
// TODO smooth
return null;
}
/**
* Compute horizontal Sobel filter
*
* @param gray a HxW float array
* @return a HxW float array
*/
public static float[][] sobelX(float[][] gray) {
// TODO sobelX
return null;
}
/**
* Compute vertical Sobel filter
*
* @param gray a HxW float array
* @return a HxW float array
*/
public static float[][] sobelY(float[][] gray) {
// TODO sobelY
return null;
}
/**
* Compute the magnitude of combined Sobel filters
*
* @param gray a HxW float array
* @return a HxW float array
*/
public static float[][] sobel(float[][] gray) {
// TODO sobel
return null;
}
}
|