我正在尝试使用 ImageJ 库生成具有 4 个灰度级的输出图像并显示它,但我在这一行的 reduceBy 方法中遇到错误
out.getPixel(r, c) = (in.getPixel(r, c) / factor) * factor;
它说赋值的左边必须是一个变量,但它肯定是一个变量吗?
导入 ij.ImagePlus;导入 iptoolkit.*;
公共类 ReduceGreyLevelsIJ {
public static void main(String[] args) {
String imageDir = "C:/Users/John/Dropbox/finalYear/Project/Leaves/";
MainWindow mw = new MainWindow();
ImagePlus src = new ImagePlus(imageDir +"ashLeafBW.tif");
ImagePlus dst1 = new ImagePlus();
src.show("Original");
reduceBy(64, src, dst1);
dst1.show("4 Grey Levels");
}
static void reduceBy(int factor, ImagePlus in, ImagePlus out) {
for (int r = 0; r < in.getHeight(); r++) {
for (int c = 0; c < in.getWidth(); c++) {
out.getPixel(r, c) = (in.getPixel(r, c) / factor) * factor;
} // c
} // r
} // reduceBy
}