我正在尝试计算灰度图像的区域,我知道如果它是缓冲图像,我可以使用 getRGB(),但我使用的是工具包,因此它是一个 int 图像。我只想问我如何获得像素值?我在下面包含了我的代码
import iptoolkit.*;
public class FindArea {
public static void main(String[] args) {
String imageDir = "C:/Users/John/Dropbox/finalYear/Project/Leaves/";
MainWindow mw = new MainWindow();
int area = 0;
IntImage src = new IntImage(imageDir + "bg7.jpg", 256, 256);
src.displayImage(); //displays the image in a window
for (int row = 0; row <= src.getRows(); row++)
{
for (int col=0; col <= src.getCols(); col++)
{
//if(src.pixels[row][col] >= 0)
area++;
}
}
System.out.print("The area of the leaf is:" +area);
}