以下のコードがあり、正常にコンパイルされます。デバッグを行ったところ、画像ファイルを認識し、寸法を確認し、getDimensions() メソッドを使用してスライス数を確認できました。ただし、 getPixel(x,y) メソッドを使用しようとすると。それは私にすべて0の配列を返し続けます。私のイメージは真っ黒ではありません。
何が起こっているのかわかりません。しかし、私はいくつかの助けを使うことができました。
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.imageio.ImageIO;
import ij.ImagePlus;
import java.util.ArrayList;
public class Test{
public static void main(String args[])throws IOException{
    try{
        ArrayList<Integer> totalWhitePixels = new ArrayList<Integer>(); 
        ArrayList<Integer> totalYellowPixels = new ArrayList<Integer>(); 
        ArrayList<Integer> totalBluePixels = new ArrayList<Integer>(); 
        //read image file
        ImagePlus img = new ImagePlus("C:\\Image74.tif");
        for(int n=1; n<=img.getNSlices(); n++){
            img.setSlice(n);
            int whitePixelCount = 0;
            int yellowPixelCount = 0;
            int bluePixelCount = 0;
            int testPixelCount = 0;
            //write file
            FileWriter fstream = new FileWriter("C:\\log.txt");
            BufferedWriter out = new BufferedWriter(fstream);
            //find pixel colors
            for (int y = 0; y < img.getHeight(); y++) {
                for (int x = 0; x < img.getWidth(); x++) {
                    int[] c = img.getPixel(x,y);
                    //testPixel
                    if (c[0]==0 && c[1]==0 && c[2]==0 && c[3]==0){
                        testPixelCount++;
                    }
                    //whitePixel
                    if (c[0]> 240 && c[1]> 240 && c[2]> 240) {
                            whitePixelCount++;
                    }
                    //yellowPixel
                    if (c[0]> 240 && c[1]> 240 && c[2]> 0){
                        yellowPixelCount++; 
                    }
                    //bluePixel
                    if (c[0]> 0 && c[1]> 0 && c[2]> 240){
                            bluePixelCount++;
                    }
                }
            }
            //System.out.println(whitePixelCount + "." + yellowPixelCount + "." + bluePixelCount);
            //System.out.println(testPixelCount);
            totalWhitePixels.add(whitePixelCount);
            totalYellowPixels.add(yellowPixelCount);
            totalBluePixels.add(bluePixelCount);
        }
    }
    catch (IOException e) {
            e.printStackTrace();
    }   
}
}