Java Code Examples for ij.process.FloatProcessor#setMask()

The following examples show how to use ij.process.FloatProcessor#setMask() . 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: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor modulo(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a%b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    float tmp;
    for (int i = 0, im = a.getWidth(); i < im; i++) {
        for (int j = 0, jm = a.getHeight(); j < jm; j++) {
            tmp = a.getf(i, j) / b.getf(i, j);
            res.setf(i, j, a.getf(i, j) - (((float)((int)tmp)) * b.getf(i, j)));
        }
    }
    return res;
}
 
Example 2
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relNeq(Double val, FloatProcessor mat) {
    float v = val.floatValue();
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    for(int x = 0; x < mat.getWidth(); x++) {
        for(int y = 0; y < mat.getHeight(); y++) {
            res.setf(x, y, ((mat.getf(x, y) != v) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 3
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relEq(Double val, FloatProcessor mat) {
    float v = val.floatValue();
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    for(int x = 0; x < mat.getWidth(); x++) {
        for(int y = 0; y < mat.getHeight(); y++) {
            res.setf(x, y, ((mat.getf(x, y) == v) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 4
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor logOr(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a|b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, (((a.getf(x, y) != 0.0f) || (b.getf(x, y) != 0.0f)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 5
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor logAnd(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a&b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, (((a.getf(x, y) != 0.0f) && (b.getf(x, y) != 0.0f)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 6
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relLt(FloatProcessor mat, Double val) {
    float v = val.floatValue();
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    for(int x = 0; x < mat.getWidth(); x++) {
        for(int y = 0; y < mat.getHeight(); y++) {
            res.setf(x, y, ((mat.getf(x, y) < v) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 7
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relLt(Double val, FloatProcessor mat) {
    float v = val.floatValue();
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    for(int x = 0; x < mat.getWidth(); x++) {
        for(int y = 0; y < mat.getHeight(); y++) {
            res.setf(x, y, ((v < mat.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 8
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relLt(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) < b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 9
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relGt(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) > b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 10
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor relNeq(FloatProcessor a, FloatProcessor b) {
    if((a.getWidth() != b.getWidth()) || (a.getHeight()!= b.getHeight())) {
        throw new IllegalArgumentException("Error during evaluation of `a<b` expression! Both operands must be of the same size!");
    }
    FloatProcessor res = new FloatProcessor(a.getWidth(), a.getHeight());
    res.setMask(a.getMask() != null ? a.getMask(): b.getMask());
    for(int x = 0; x < a.getWidth(); x++) {
        for(int y = 0; y < a.getHeight(); y++) {
            res.setf(x, y, ((a.getf(x, y) != b.getf(x, y)) ? 1.0f : 0.0f));
        }
    }
    return res;
}
 
Example 11
Source File: BiplaneAnalysisPlugIn.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
private FloatProcessor getRoiProcessor(ImagePlus imp, Roi roi, int index) {
    ImageProcessor ip = imp.getStack().getProcessor(index);
    ip.setRoi(roi.getBounds());
    FloatProcessor fp = subtract(ip.crop().convertToFloatProcessor(), (float) CameraSetupPlugIn.getOffset());
    float minVal = VectorMath.min((float[]) fp.getPixels());
    if(minVal < 0) {
        IJ.log("\\Update:Camera base level is set higher than values in the image!");
        fp = add(-minVal, fp);
    }
    fp.setMask(roi.getMask());
    return fp;
}
 
Example 12
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Calculate a {@code val}-th power of an image {@code fp}.
 * 
 * @param val {@code val}-th power of {@code fp}
 * @param fp an input image
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fpv = fp ^ val}
 */
public static FloatProcessor power(FloatProcessor fp, float val) {
    FloatProcessor out = new FloatProcessor(fp.getWidth(), fp.getHeight());
    out.setMask(fp.getMask());
    for (int i = 0, im = fp.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp.getHeight(); j < jm; j++) {
            out.setf(i, j, (float)pow((double)fp.getPixelValue(i, j), (double)val));
        }
    }

    return out;
}
 
Example 13
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Divide a scalar value by values from an image.
 * 
 * @param val an input value which the input image ({@code fp}) will divide
 * @param fp an input image
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fpv = val / fp}
 */
public static FloatProcessor divide(float val, FloatProcessor fp) {
    FloatProcessor out = new FloatProcessor(fp.getWidth(), fp.getHeight());
    out.setMask(fp.getMask());
    for (int i = 0, im = fp.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp.getHeight(); j < jm; j++) {
            out.setf(i, j, val / fp.getPixelValue(i, j));
        }
    }

    return out;
}
 
Example 14
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Divide values of one image by values of the other image.
 * 
 * The images are required to be of the same size.
 *
 * @param fp1 an input image which the other input image ({@code fp2}) will be divided by
 * @param fp2 another input image which will divide the {@code fp1}
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fp3 = fp1 / fp2}
 */
public static FloatProcessor divide(FloatProcessor fp1, FloatProcessor fp2) {
    assert (fp1.getWidth() == fp2.getWidth());
    assert (fp1.getHeight() == fp2.getHeight());

    FloatProcessor out = new FloatProcessor(fp1.getWidth(), fp1.getHeight());
    out.setMask(fp1.getMask() != null ? fp1.getMask(): fp2.getMask());
    for (int i = 0, im = fp1.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp1.getHeight(); j < jm; j++) {
            out.setf(i, j, fp1.getPixelValue(i, j) / fp2.getPixelValue(i, j));
        }
    }

    return out;
}
 
Example 15
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Multiply two images.
 * 
 * The images are required to be of the same size.
 *
 * @param fp1 an input image which the other input image ({@code fp2}) will be multiplied with
 * @param fp2 another input image which will be multiplied with {@code fp1}
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fp3 = fp1 * fp2}
 */
public static FloatProcessor multiply(FloatProcessor fp1, FloatProcessor fp2) {
    assert (fp1.getWidth() == fp2.getWidth());
    assert (fp1.getHeight() == fp2.getHeight());

    FloatProcessor out = new FloatProcessor(fp1.getWidth(), fp1.getHeight());
    out.setMask(fp1.getMask() != null ? fp1.getMask(): fp2.getMask());
    for (int i = 0, im = fp1.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp1.getHeight(); j < jm; j++) {
            out.setf(i, j, fp1.getPixelValue(i, j) * fp2.getPixelValue(i, j));
        }
    }

    return out;
}
 
Example 16
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Subtract an image from a scalar.
 * 
 * @param val an input value which the input image ({@code fp}) will be subtracted from
 * @param fp an input image
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fpv = val - fp}
 */
public static FloatProcessor subtract(float val, FloatProcessor fp) {
    FloatProcessor out = new FloatProcessor(fp.getWidth(), fp.getHeight());
    out.setMask(fp.getMask());
    for (int i = 0, im = fp.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp.getHeight(); j < jm; j++) {
            out.setf(i, j, val - fp.getPixelValue(i, j));
        }
    }

    return out;
}
 
Example 17
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Subtract one image to the other.
 * 
 * The images are required to be of the same size.
 *
 * @param fp1 an input image which the other input image ({@code fp2}) will be subtracted from
 * @param fp2 another input image which will be subtracted from {@code fp1}
 * @return a <strong>new instance</strong> of FloatProcessor: {@mathjax fp3 = fp1 - fp2}
 */
public static FloatProcessor subtract(FloatProcessor fp1, FloatProcessor fp2) {
    assert (fp1.getWidth() == fp2.getWidth());
    assert (fp1.getHeight() == fp2.getHeight());

    FloatProcessor out = new FloatProcessor(fp1.getWidth(), fp1.getHeight());
    out.setMask(fp1.getMask() != null ? fp1.getMask(): fp2.getMask());
    for (int i = 0, im = fp1.getWidth(); i < im; i++) {
        for (int j = 0, jm = fp1.getHeight(); j < jm; j++) {
            out.setf(i, j, fp1.getPixelValue(i, j) - fp2.getPixelValue(i, j));
        }
    }

    return out;
}
 
Example 18
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor modulo(float val, FloatProcessor mat) {
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    float tmp;
    for (int i = 0, im = mat.getWidth(); i < im; i++) {
        for (int j = 0, jm = mat.getHeight(); j < jm; j++) {
            tmp = val / mat.getf(i, j);
            res.setf(i, j, val - (((float)((int)tmp)) * mat.getf(i, j)));
        }
    }
    return res;
}
 
Example 19
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
public static FloatProcessor modulo(FloatProcessor mat, float val) {
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight());
    res.setMask(mat.getMask());
    float tmp;
    for (int i = 0, im = mat.getWidth(); i < im; i++) {
        for (int j = 0, jm = mat.getHeight(); j < jm; j++) {
            tmp = mat.getf(i, j) / val;
            res.setf(i, j, mat.getf(i, j) - (((float)((int)tmp)) * val));
        }
    }
    return res;
}
 
Example 20
Source File: ImageMath.java    From thunderstorm with GNU General Public License v3.0 4 votes vote down vote up
public static FloatProcessor abs(FloatProcessor mat) {
    FloatProcessor res = new FloatProcessor(mat.getWidth(), mat.getHeight(), (float [])mat.getPixelsCopy(), null);
    res.abs();
    res.setMask(mat.getMask());
    return res;
}