Java Code Examples for ij.process.ImageProcessor#getPixelValue()

The following examples show how to use ij.process.ImageProcessor#getPixelValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IJHysteresis.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Double thresholding
 *
 * @param ima original image
 * @param T1  high threshold
 * @param T2  low threshold
 * @return "trinarised" image
 */
ImageProcessor trin(ImageProcessor ima, float T1, float T2) {
    int la = ima.getWidth();
    int ha = ima.getHeight();
    ByteProcessor res = new ByteProcessor(la, ha);
    float pix;

    for (int x = 0; x < la; x++) {
        for (int y = 0; y < ha; y++) {
            pix = ima.getPixelValue(x, y);
            if (pix >= T1) {
                res.putPixel(x, y, 255);
            } else if (pix >= T2) {
                res.putPixel(x, y, 128);
            }
        }
    }
    return res;
}