Мне нужно написать программу, которая заменяет каждый пиксель на медианное значение и на 8 соседей. То, что у меня есть, будет скомпилировано, но когда я попытаюсь создать новое изображение, получаю несколько ошибок. Помощь приветствуется.Медиана фильтра изображения pgm
Вот StackTrace:
Exception in thread "main" java.lang.ClassCastException: [I cannot be cast to java.lang.Comparable
at java.util.ComparableTimSort.countRunAndMakeAscending(ComparableTimSort.java:290)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:171)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:146)
at java.util.Arrays.sort(Arrays.java:472)
at ImageProcessing.median(ImageProcessing.java:25
И вот мой код:
public static int [] [] median(int [] [] image) {
int height = image.length;
int width = image[0].length;
int [] [] result = new int [height] [width];
for (int col = 0 ; col < image.length ; col++) {
result[0][col] = image[0][col];
result[height - 1][col] = image[height - 1][col];
}
for (int row = 0 ; row < image[0].length ; row++) {
result[row][0] = image[row][0];
result[row][width - 1] = image[row][width - 1];
}
for (int row = 1 ; row < height - 1 ; row++) {
for (int col = 1 ; col < width - 1 ; col++) {
Arrays.sort(image);
result[row][col] = image[row][col]/2;
}
}
return result;
}
Пожалуйста, сообщите, какие ошибки вы получаете. –