简体   繁体   English

imagej总是显示黑色图像

[英]imagej always shows black images

for an assignment I have to display an image using imagej in java. 对于作业,我必须在Java中使用imagej显示图像。 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? 如果值为0,应该至少是白色,不是吗? (FYI: imageSizeX=imageSizeY=256) (仅供参考:imageSizeX = imageSizeY = 256)

.putPixel uses the conversion Float.intBitsToFloat . .putPixel使用转换Float.intBitsToFloat

If you want a direct access to the pixels, you can use setf(int x, int y, float value) . 如果要直接访问像素,可以使用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) . 而且,如果已经将像素放入数组中,则可以使用构造函数立即设置像素值FloatProcessor(int width, int height, int[] pixels)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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