/** * This function produces the Laplacian of input image. See this Neva * * @param nImages number of images to be blurred. If 2D image then nImage = 1, if 3D image where * each image is to processed independently then nImages equals the number of images in the * volume. */ private void calcStoreInDest2D(int nImages) { int i, s; int length; float[] buffer; float[] resultBuffer; float lap; try { length = srcImage.getSliceSize(); buffer = new float[length]; resultBuffer = new float[length]; fireProgressStateChanged(srcImage.getImageName(), "Calculating the Laplacian ..."); } catch (OutOfMemoryError e) { buffer = null; resultBuffer = null; errorCleanUp("Algorithm Laplacian exportData: Out of memory", true); return; } try { srcImage.exportData(0, length, buffer); // locks and releases lock } catch (IOException error) { displayError("Algorithm Gaussian Blur: Image(s) locked"); setCompleted(false); destImage.releaseLock(); return; } float[] sigs = new float[2]; for (s = 1; (s <= 8) && !threadStopped; s++) { sigs[0] = s; sigs[1] = s; makeKernels2D(sigs); fireProgressStateChanged(Math.round((float) (s) / 8 * 100)); for (i = 0; (i < length) && !threadStopped; i++) { lap = AlgorithmConvolver.convolve2DPtMed(i, srcImage.getExtents(), buffer, kExtents, GxxData); if (lap > resultBuffer[i]) { resultBuffer[i] = lap; } } } if (threadStopped) { finalize(); return; } try { destImage.importData(0, resultBuffer, true); } catch (IOException error) { errorCleanUp("Algorithm Gaussian Blur: Image(s) locked", false); return; } setCompleted(true); }
/** * Calculates the Laplacian image and replaces the source image with the new image. * * @param nImages number of images to be blurred. If 2D image then nImage = 1, if 3D image where * each image is to processed independently then nImages equals the number of images in the * volume. * @param buffer DOCUMENT ME! * @param extents DOCUMENT ME! * @return resultBuffer */ private float[] calcInPlace2DBuffer(int nImages, float[] buffer, int[] extents) { int i, s; int length; float[] resultBuffer; float lap; try { if (buffer == null) { length = srcImage.getSliceSize(); buffer = new float[length]; } else { length = buffer.length; } resultBuffer = new float[length * nImages]; sBuffer = new byte[length * nImages]; if (srcImage != null) { fireProgressStateChanged(srcImage.getImageName(), "Calculating the Laplacian ..."); } else { fireProgressStateChanged("Medialness", "Calculating the Laplacian ..."); } } catch (OutOfMemoryError e) { buffer = null; resultBuffer = null; sBuffer = null; errorCleanUp("Algorithm Laplacian exportData: Out of memory", true); return null; } try { if (srcImage != null) { srcImage.exportData(0, length, buffer); // locks and releases lock } } catch (IOException error) { buffer = null; resultBuffer = null; System.gc(); errorCleanUp("Algorithm Laplacian: " + error, false); return null; } float[] sigs = new float[2]; for (s = 1; (s <= 8) && !threadStopped; s++) { sigs[0] = s; sigs[1] = s; makeKernels2D(sigs); fireProgressStateChanged(Math.round((float) (s) / 8 * 100)); for (i = 0; (i < length) && !threadStopped; i++) { lap = AlgorithmConvolver.convolve2DPtMed(i, extents, buffer, kExtents, GxxData); if (lap > resultBuffer[i]) { resultBuffer[i] = lap; } sBuffer[i] = (byte) s; } } return resultBuffer; }