简体   繁体   English

快速处理ImagePlus中每个像素的方法

[英]Fast way to manipulate each pixel from ImagePlus

Hello I need to access every pixels of an ImagePlus for image analysis. 您好,我需要访问ImagePlus的每个像素进行图像分析。

Because of the huge amount of images to process, I was wondering if there are special effective ways/methods to access and/or modify each pixel from an imagePlus? 由于要处理的图像数量巨大,我想知道是否有特殊有效的方法/方法来访问和/或修改imagePlus中的每个像素? The only idea I naturally come out with is double for-looping through the image matrix, which takes me several dozens of seconds to achieve on a 1000x1000 image. 我自然想到的唯一想法是在图像矩阵中进行双循环,这花了我数十秒才能实现1000x1000的图像。 Here is my code: 这是我的代码:

ImagePlus Iorg = IJ.openImage("Demo1.png");
int[] pix = Iorg.getPixel(5, 5);
if(Iorg.getSlice() != 1) {
    System.exit(0);
}

for(int w=0; w< Iorg.getDimensions()[0]; w++) {
    for(int h=0; h<Iorg.getDimensions()[1]; h++) {
       System.out.println(w + " x " + h);
       // DO what needs to be done      
    }
}

Any idea? 任何想法?

Since images are uchar , what you want to do is the equivalent of 由于图像是uchar ,因此您要做的是

if(selected_pixel==255) 
     selected_pixel = 1; 
else 
     selected_pixel = 0 

You can create mask, that would be easier. 您可以创建遮罩,这样会更容易。 I don't know in java ImagePlus but in matlab it is mask = image==255; 我在Java ImagePlus中不知道,但是在matlab中它是mask = image==255; .

Try to use those kind of matrix operations according to your need. 尝试根据需要使用那些矩阵运算。 I'm sure these methods should be somewhere inside the library(if ImagePlus is image processing library.) 我确定这些方法应该在库中的某个位置(如果ImagePlus是图像处理库。)

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

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