我想在 java 中使用 ImageJ 框架分析图像。如何打开图像?我需要一个 ImageProcessor
对象才能生成直方图。这是我到目前为止的代码:
public void run(ImageProcessor ip) {
int[] H = new int[256]; // histogram array
int w = ip.getWidth();
int h = ip.getHeight();
for (int v = 0; v < h; v++) {
for (int u = 0; u < w; u++) {
int i = ip.getPixel(u, v);
H[i] = H[i] + 1;
}
}
// ... histogram H[] can now be used
}
最佳答案
我处理不适合 ColorProcesser 的医学灰度图像。在那种情况下,我使用
Opener opener = new Opener();
String imageFilePath = "somePath";
ImagePlus imp = opener.openImage(imageFilePath);
ImageProcesser ip = imp.getProcessor(); // ImageProcessor from ImagePlus
关于java - 如何在 java 中使用 ImageJ 打开图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11441126/