/* * (non-Javadoc) * @see fr.unistra.pelican.Algorithm#launch() */ public void launch() { int xdim = input.getXDim(); int ydim = input.getYDim(); int zdim = input.getZDim(); int tdim = input.getTDim(); int bdim = input.getBDim(); int vx = (int) (xdim * rx); int vy = (int) (ydim * ry); int vz = (int) (zdim * rz); int vt = (int) (tdim * rt); int vb = (int) (bdim * rb); output = ResamplingByValue.exec(input, vx, vy, vz, vt, vb, resamplingMethod); }
public void launch() { System.gc(); int xDim = inputImage.getXDim(); int yDim = inputImage.getYDim(); int layer = inputImage.getBDim(); int imageDim = xDim * yDim; int[] colors = new int[imageDim]; int shift = 0; // image grise if (layer == 1) { for (int i = 0; i < imageDim; i++) { colors[i] = Color.rgb( inputImage.getPixelByte(i), inputImage.getPixelByte(i), inputImage.getPixelByte(i)); } } // sans alpha if (layer == 3) { for (int i = 0; i < imageDim; i++) { colors[i] = Color.rgb( inputImage.getPixelByte(shift++), inputImage.getPixelByte(shift++), inputImage.getPixelByte(shift++)); } // avec alpha } else if (layer == 4) { for (int i = 0; i < imageDim; i++) { colors[i] = Color.argb( inputImage.getPixelByte(shift++), inputImage.getPixelByte(shift++), inputImage.getPixelByte(shift++), inputImage.getPixelByte(shift++)); } } // on n'a plus besoin de l'image d'origine inputImage = null; System.gc(); outputBitmap = Bitmap.createBitmap(colors, xDim, yDim, Bitmap.Config.valueOf("ARGB_8888")); }
/* * (non-Javadoc) * * @see fr.unistra.pelican.Algorithm#launch() */ public void launch() throws AlgorithmException { int bdim = input.getBDim(); int tdim = input.getTDim(); int zdim = input.getZDim(); int ydim = input.getYDim(); int xdim = input.getXDim(); output = new DoubleImage(xdim, ydim, zdim, tdim, bdim); output.copyAttributes(input); double kok2 = Math.sqrt(2.0); if (input instanceof BooleanImage) throw new AlgorithmException("BooleanImages are not supported"); switch (operation) { case GRADY: for (int b = 0; b < bdim; b++) { for (int t = 0; t < tdim; t++) { for (int z = 0; z < zdim; z++) { for (int y = 1; y < ydim - 1; y++) { for (int x = 1; x < xdim - 1; x++) { double tmp = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x, y - 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b); tmp = input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x, y + 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmp; output.setPixelXYZTBDouble(x, y, z, t, b, tmp); } } } } } break; case GRADX: for (int b = 0; b < bdim; b++) { for (int t = 0; t < tdim; t++) { for (int z = 0; z < zdim; z++) { for (int y = 1; y < ydim - 1; y++) { for (int x = 1; x < xdim - 1; x++) { double tmp = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x - 1, y, z, t, b) + input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b); tmp = input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x + 1, y, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmp; output.setPixelXYZTBDouble(x, y, z, t, b, tmp); } } } } } break; case NORM: for (int b = 0; b < bdim; b++) { for (int t = 0; t < tdim; t++) { for (int z = 0; z < zdim; z++) { for (int y = 1; y < ydim - 1; y++) { for (int x = 1; x < xdim - 1; x++) { double tmpy = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x, y - 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b); tmpy = input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x, y + 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmpy; double tmpx = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x - 1, y, z, t, b) + input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b); tmpx = input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x + 1, y, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmpx; double norm = Math.sqrt(tmpx * tmpx + tmpy * tmpy); output.setPixelXYZTBDouble(x, y, z, t, b, norm); } } } } } break; default: for (int b = 0; b < bdim; b++) { for (int t = 0; t < tdim; t++) { for (int z = 0; z < zdim; z++) { for (int y = 1; y < ydim - 1; y++) { for (int x = 1; x < xdim - 1; x++) { double tmpy = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x, y - 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b); tmpy = input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b) + 2 * input.getPixelXYZTBDouble(x, y + 1, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmpy; double tmpx = input.getPixelXYZTBDouble(x - 1, y - 1, z, t, b) + kok2 * input.getPixelXYZTBDouble(x - 1, y, z, t, b) + input.getPixelXYZTBDouble(x - 1, y + 1, z, t, b); tmpx = input.getPixelXYZTBDouble(x + 1, y - 1, z, t, b) + 2 * input.getPixelXYZTBDouble(x + 1, y, z, t, b) + input.getPixelXYZTBDouble(x + 1, y + 1, z, t, b) - tmpx; double norm = Math.atan(tmpy / tmpx) - 3 * Math.PI / 4; output.setPixelXYZTBDouble(x, y, z, t, b, norm); } } } } } } }
/* * (non-Javadoc) * * @see fr.unistra.pelican.Algorithm#launch() */ public void launch() throws AlgorithmException { if (!Image.haveSameDimensions(inputImage1, inputImage2)) throw new AlgorithmException("Minimum: input images must have same dimensions!"); outputImage = inputImage1.copyImage(false); int size = inputImage1.size(); MaskStack mask = new MaskStack(MaskStack.OR); mask.push(inputImage1.getMask()); mask.push(inputImage2.getMask()); outputImage.setMask(mask); boolean isHere1, isHere2; for (int i = 0; i < size; ++i) { isHere1 = inputImage1.isPresent(i); isHere2 = inputImage2.isPresent(i); double pixel1 = inputImage1.getPixelDouble(i); double pixel2 = inputImage2.getPixelDouble(i); if (isHere1 && isHere2) outputImage.setPixelDouble(i, pixel1 < pixel2 ? pixel1 : pixel2); else if (isHere1 && !isHere2) outputImage.setPixelDouble(i, pixel1); else if (!isHere1 && isHere2) outputImage.setPixelDouble(i, pixel2); } }