Java Code Examples for ij.process.ShortProcessor#get()
The following examples show how to use
ij.process.ShortProcessor#get() .
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: DistanceTransform5x5Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
private void forwardScan(ShortProcessor distMap, ImageProcessor labelImage) { this.fireStatusChanged(new AlgoEvent(this, "Forward Scan")); // Initialize pairs of offset and weights int[] dx = new int[]{-1, +1, -2, -1, 0, +1, +2, -1}; int[] dy = new int[]{-2, -2, -1, -1, -1, -1, -1, 0}; short[] dw = new short[] { weights[2], weights[2], weights[2], weights[1], weights[0], weights[1], weights[2], weights[0] }; // size of image int sizeX = labelImage.getWidth(); int sizeY = labelImage.getHeight(); // Iterate over pixels for (int y = 0; y < sizeY; y++) { this.fireProgressChanged(this, y, sizeY); for (int x = 0; x < sizeX; x++) { // get current label int label = (int) labelImage.getf(x, y); // do not process background pixels if (label == 0) continue; // current distance value int currentDist = distMap.get(x, y); int newDist = currentDist; // iterate over neighbors for (int i = 0; i < dx.length; i++) { // compute neighbor coordinates int x2 = x + dx[i]; int y2 = y + dy[i]; // check bounds if (x2 < 0 || x2 >= sizeX) continue; if (y2 < 0 || y2 >= sizeY) continue; if ((int) labelImage.getf(x2, y2) != label) { // Update with distance to nearest different label newDist = Math.min(newDist, dw[i]); } else { // Increment distance newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]); } } if (newDist < currentDist) { distMap.set(x, y, newDist); } } } this.fireProgressChanged(this, sizeY, sizeY); }
Example 2
Source File: DistanceTransform5x5Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
private void backwardScan(ShortProcessor distMap, ImageProcessor labelImage) { this.fireStatusChanged(new AlgoEvent(this, "Backward Scan")); // Initialize pairs of offset and weights int[] dx = new int[]{+1, -1, +2, +1, 0, -1, -2, +1}; int[] dy = new int[]{+2, +2, +1, +1, +1, +1, +1, 0}; short[] dw = new short[] { weights[2], weights[2], weights[2], weights[1], weights[0], weights[1], weights[2], weights[0] }; // size of image int sizeX = labelImage.getWidth(); int sizeY = labelImage.getHeight(); // Iterate over pixels for (int y = sizeY-1; y >= 0; y--) { this.fireProgressChanged(this, sizeY-1-y, sizeY); for (int x = sizeX-1; x >= 0; x--) { // get current label int label = (int) labelImage.getf(x, y); // do not process background pixels if (label == 0) continue; // current distance value int currentDist = distMap.get(x, y); int newDist = currentDist; // iterate over neighbors for (int i = 0; i < dx.length; i++) { // compute neighbor coordinates int x2 = x + dx[i]; int y2 = y + dy[i]; // check bounds if (x2 < 0 || x2 >= sizeX) continue; if (y2 < 0 || y2 >= sizeY) continue; if ((int) labelImage.getf(x2, y2) != label) { // Update with distance to nearest different label newDist = Math.min(newDist, dw[i]); } else { // Increment distance newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]); } } if (newDist < currentDist) { distMap.set(x, y, newDist); } } } this.fireProgressChanged(this, sizeY, sizeY); }
Example 3
Source File: DistanceTransform3x3Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
private void forwardScan(ShortProcessor distMap, ImageProcessor labelImage) { this.fireStatusChanged(new AlgoEvent(this, "Forward Scan")); int[] dx = new int[]{-1, 0, +1, -1}; int[] dy = new int[]{-1, -1, -1, 0}; int[] dw = new int[]{weights[1], weights[0], weights[1], weights[0]}; // size of image int sizeX = labelImage.getWidth(); int sizeY = labelImage.getHeight(); // Iterate over pixels for (int y = 0; y < sizeY; y++) { this.fireProgressChanged(this, y, sizeY); for (int x = 0; x < sizeX; x++) { // get current label int label = (int) labelImage.getf(x, y); // do not process background pixels if (label == 0) continue; // current distance value int currentDist = distMap.get(x, y); int newDist = currentDist; // iterate over neighbors for (int i = 0; i < dx.length; i++) { // compute neighbor coordinates int x2 = x + dx[i]; int y2 = y + dy[i]; // check bounds if (x2 < 0 || x2 >= sizeX) continue; if (y2 < 0 || y2 >= sizeY) continue; if ((int) labelImage.getf(x2, y2) != label) { // Update with distance to nearest different label newDist = Math.min(newDist, dw[i]); } else { // Increment distance newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]); } } if (newDist < currentDist) { distMap.set(x, y, newDist); } } } this.fireProgressChanged(this, sizeY, sizeY); }
Example 4
Source File: DistanceTransform3x3Short.java From MorphoLibJ with GNU Lesser General Public License v3.0 | 4 votes |
private void backwardScan(ShortProcessor distMap, ImageProcessor labelImage) { this.fireStatusChanged(new AlgoEvent(this, "Backward Scan")); int[] dx = new int[]{+1, 0, -1, +1}; int[] dy = new int[]{+1, +1, +1, 0}; int[] dw = new int[]{weights[1], weights[0], weights[1], weights[0]}; // size of image int sizeX = labelImage.getWidth(); int sizeY = labelImage.getHeight(); // Iterate over pixels for (int y = sizeY-1; y >= 0; y--) { this.fireProgressChanged(this, sizeY-1-y, sizeY); for (int x = sizeX-1; x >= 0; x--) { // get current label int label = (int) labelImage.getf(x, y); // do not process background pixels if (label == 0) continue; // current distance value int currentDist = distMap.get(x, y); int newDist = currentDist; // iterate over neighbors for (int i = 0; i < dx.length; i++) { // compute neighbor coordinates int x2 = x + dx[i]; int y2 = y + dy[i]; // check bounds if (x2 < 0 || x2 >= sizeX) continue; if (y2 < 0 || y2 >= sizeY) continue; if ((int) labelImage.getf(x2, y2) != label) { // Update with distance to nearest different label newDist = Math.min(newDist, dw[i]); } else { // Increment distance newDist = Math.min(newDist, distMap.get(x2, y2) + dw[i]); } } if (newDist < currentDist) { distMap.set(x, y, newDist); } } } this.fireProgressChanged(this, sizeY, sizeY); }