简体   繁体   中英

imagej always shows black images

for an assignment I have to display an image using imagej in java. So I used the following code:

    FloatProcessor abc=new FloatProcessor(imageSizeX,imageSizeY);
        for (int i=0;i<imageSizeX;i++){
              for(int j=0;j<imageSizeY;j++){
              abc.putPixel(i, j, 100);
              }
        }
        ImagePlus im=new ImagePlus("test",abc);
        im.show();

but the Image I get is always completely black. Can you tell me what the mistake is? It should at least be white if the value was 0 shouldn't it? (FYI: imageSizeX=imageSizeY=256)

.putPixel uses the conversion Float.intBitsToFloat .

If you want a direct access to the pixels, you can use setf(int x, int y, float value) .

Moreover, if you already have the pixels into an array, you can use the constructors to immediately set the pixel values FloatProcessor(int width, int height, int[] pixels) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM