java.awt.image.ConvolveOp Java Examples
The following examples show how to use
java.awt.image.ConvolveOp.
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: BufferedBufImgOps.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #2
Source File: Band.java From javaanpr with Educational Community License v2.0 | 6 votes |
public void fullEdgeDetector(BufferedImage source) { float[] verticalMatrix = {-1, 0, 1, -2, 0, 2, -1, 0, 1}; float[] horizontalMatrix = {-1, -2, -1, 0, 0, 0, 1, 2, 1}; BufferedImage i1 = Photo.createBlankBi(source); BufferedImage i2 = Photo.createBlankBi(source); new ConvolveOp(new Kernel(3, 3, verticalMatrix), ConvolveOp.EDGE_NO_OP, null).filter(source, i1); new ConvolveOp(new Kernel(3, 3, horizontalMatrix), ConvolveOp.EDGE_NO_OP, null).filter(source, i2); int w = source.getWidth(); int h = source.getHeight(); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { float sum = 0.0f; sum += Photo.getBrightness(i1, x, y); sum += Photo.getBrightness(i2, x, y); Photo.setBrightness(source, x, y, Math.min(1.0f, sum)); } } }
Example #3
Source File: BufferedBufImgOps.java From hottub with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #4
Source File: BufferedBufImgOps.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #5
Source File: BufferedBufImgOps.java From Bytecoder with Apache License 2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #6
Source File: BufferedBufImgOps.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #7
Source File: BufferedBufImgOps.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #8
Source File: BufferedBufImgOps.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #9
Source File: EdgeNoOpCrash.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void crashTest() { Raster src = createSrcRaster(); WritableRaster dst = createDstRaster(); ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP); try { op.filter(src, dst); } catch (ImagingOpException e) { /* * The test pair of source and destination rasters * may cause failure of the medialib convolution routine, * so this exception is expected. * * The JVM crash is the only manifestation of this * test failure. */ } System.out.println("Test PASSED."); }
Example #10
Source File: EdgeNoOpCrash.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void crashTest() { Raster src = createSrcRaster(); WritableRaster dst = createDstRaster(); ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP); try { op.filter(src, dst); } catch (ImagingOpException e) { /* * The test pair of source and destination rasters * may cause failure of the medialib convolution routine, * so this exception is expected. * * The JVM crash is the only manifestation of this * test failure. */ } System.out.println("Test PASSED."); }
Example #11
Source File: EdgeNoOpCrash.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static void crashTest() { Raster src = createSrcRaster(); WritableRaster dst = createDstRaster(); ConvolveOp op = createConvolveOp(ConvolveOp.EDGE_NO_OP); try { op.filter(src, dst); } catch (ImagingOpException e) { /* * The test pair of source and destination rasters * may cause failure of the medialib convolution routine, * so this exception is expected. * * The JVM crash is the only manifestation of this * test failure. */ } System.out.println("Test PASSED."); }
Example #12
Source File: BufferedBufImgOps.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void enableConvolveOp(RenderQueue rq, SurfaceData srcData, ConvolveOp cop) { // assert rq.lock.isHeldByCurrentThread(); boolean edgeZero = cop.getEdgeCondition() == ConvolveOp.EDGE_ZERO_FILL; Kernel kernel = cop.getKernel(); int kernelWidth = kernel.getWidth(); int kernelHeight = kernel.getHeight(); int kernelSize = kernelWidth * kernelHeight; int sizeofFloat = 4; int totalBytesRequired = 4 + 8 + 12 + (kernelSize * sizeofFloat); RenderBuffer buf = rq.getBuffer(); rq.ensureCapacityAndAlignment(totalBytesRequired, 4); buf.putInt(ENABLE_CONVOLVE_OP); buf.putLong(srcData.getNativeOps()); buf.putInt(edgeZero ? 1 : 0); buf.putInt(kernelWidth); buf.putInt(kernelHeight); buf.put(kernel.getKernelData(null)); }
Example #13
Source File: BufferedBufImgOps.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) { if (biop instanceof ConvolveOp) { disableConvolveOp(rq); } else if (biop instanceof RescaleOp) { disableRescaleOp(rq); } else if (biop instanceof LookupOp) { disableLookupOp(rq); } else { throw new InternalError("Unknown BufferedImageOp"); } }
Example #14
Source File: BufferedBufImgOps.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData, BufferedImage srcImg, BufferedImageOp biop) { if (biop instanceof ConvolveOp) { enableConvolveOp(rq, srcData, (ConvolveOp)biop); } else if (biop instanceof RescaleOp) { enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop); } else if (biop instanceof LookupOp) { enableLookupOp(rq, srcData, srcImg, (LookupOp)biop); } else { throw new InternalError("Unknown BufferedImageOp"); } }
Example #15
Source File: EdgeNoOpCrash.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static ConvolveOp createConvolveOp(int edgeHint) { final int kw = 3; final int kh = 3; float[] kdata = new float[kw * kh]; float v = 1f / kdata.length; Arrays.fill(kdata, v); Kernel k = new Kernel(kw, kh, kdata); ConvolveOp op = new ConvolveOp(k, edgeHint, null); return op; }
Example #16
Source File: BufferedBufImgOps.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void enableBufImgOp(RenderQueue rq, SurfaceData srcData, BufferedImage srcImg, BufferedImageOp biop) { if (biop instanceof ConvolveOp) { enableConvolveOp(rq, srcData, (ConvolveOp)biop); } else if (biop instanceof RescaleOp) { enableRescaleOp(rq, srcData, srcImg, (RescaleOp)biop); } else if (biop instanceof LookupOp) { enableLookupOp(rq, srcData, srcImg, (LookupOp)biop); } else { throw new InternalError("Unknown BufferedImageOp"); } }
Example #17
Source File: EdgeNoOpCrash.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static ConvolveOp createConvolveOp(int edgeHint) { final int kw = 3; final int kh = 3; float[] kdata = new float[kw * kh]; float v = 1f / kdata.length; Arrays.fill(kdata, v); Kernel k = new Kernel(kw, kh, kdata); ConvolveOp op = new ConvolveOp(k, edgeHint, null); return op; }
Example #18
Source File: MlibOpsTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static BufferedImageOp getConvolveOp() { int kw = 3; int kh = 3; int size = kw * kh; float[] kdata = new float[size]; Arrays.fill(kdata, 1.0f / size); Kernel k = new Kernel(kw, kh, kdata); return new ConvolveOp(k); }
Example #19
Source File: SamePackingTypeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static BufferedImageOp createTestOp() { final int size = 1; final float v = 1f / (size * size); final float[] k_data = new float[size * size]; Arrays.fill(k_data, v); Kernel k = new Kernel(size, size, k_data); return new ConvolveOp(k); }
Example #20
Source File: OpCompatibleImageTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public OpCompatibleImageTest() { final Kernel kernel = new Kernel(3, 3, new float[] { 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f, 1f/9f}); op = new ConvolveOp(kernel); }
Example #21
Source File: ShadowFactory.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ConvolveOp getLinearBlurOp(final int size) { float[] data = new float[size * size]; float value = 1.0f / (float) (size * size); for (int i = 0; i < data.length; i++) { data[i] = value; } return new ConvolveOp(new Kernel(size, size, data)); }
Example #22
Source File: ShadowRenderer.java From SikuliNG with MIT License | 5 votes |
ConvolveOp getBlurOp(int size) { float[] data = new float[size * size]; float value = 1 / (float) (size * size); for (int i = 0; i < data.length; i++) { data[i] = value; } return new ConvolveOp(new Kernel(size, size, data)); }
Example #23
Source File: BufferedBufImgOps.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void disableBufImgOp(RenderQueue rq, BufferedImageOp biop) { if (biop instanceof ConvolveOp) { disableConvolveOp(rq); } else if (biop instanceof RescaleOp) { disableRescaleOp(rq); } else if (biop instanceof LookupOp) { disableLookupOp(rq); } else { throw new InternalError("Unknown BufferedImageOp"); } }
Example #24
Source File: ShadowFactory.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
private ConvolveOp getLinearBlurOp(final int size) { float[] data = new float[size * size]; float value = 1.0f / (float) (size * size); for (int i = 0; i < data.length; i++) { data[i] = value; } return new ConvolveOp(new Kernel(size, size, data)); }
Example #25
Source File: MlibOpsTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static BufferedImageOp getConvolveOp() { int kw = 3; int kh = 3; int size = kw * kh; float[] kdata = new float[size]; Arrays.fill(kdata, 1.0f / size); Kernel k = new Kernel(kw, kh, kdata); return new ConvolveOp(k); }
Example #26
Source File: MlibOpsTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static BufferedImageOp getConvolveOp() { int kw = 3; int kh = 3; int size = kw * kh; float[] kdata = new float[size]; Arrays.fill(kdata, 1.0f / size); Kernel k = new Kernel(kw, kh, kdata); return new ConvolveOp(k); }
Example #27
Source File: ShadowRenderer.java From SikuliX1 with MIT License | 5 votes |
ConvolveOp getBlurOp(int size) { float[] data = new float[size * size]; float value = 1 / (float) (size * size); for (int i = 0; i < data.length; i++) { data[i] = value; } return new ConvolveOp(new Kernel(size, size, data)); }
Example #28
Source File: BufferedBufImgOps.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/**************************** ConvolveOp support ****************************/ public static boolean isConvolveOpValid(ConvolveOp cop) { Kernel kernel = cop.getKernel(); int kw = kernel.getWidth(); int kh = kernel.getHeight(); // REMIND: we currently can only handle 3x3 and 5x5 kernels, // but hopefully this is just a temporary restriction; // see native shader comments for more details if (!(kw == 3 && kh == 3) && !(kw == 5 && kh == 5)) { return false; } return true; }
Example #29
Source File: EdgeNoOpCrash.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static ConvolveOp createConvolveOp(int edgeHint) { final int kw = 3; final int kh = 3; float[] kdata = new float[kw * kh]; float v = 1f / kdata.length; Arrays.fill(kdata, v); Kernel k = new Kernel(kw, kh, kdata); ConvolveOp op = new ConvolveOp(k, edgeHint, null); return op; }
Example #30
Source File: SamePackingTypeTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static BufferedImageOp createTestOp() { final int size = 1; final float v = 1f / (size * size); final float[] k_data = new float[size * size]; Arrays.fill(k_data, v); Kernel k = new Kernel(size, size, k_data); return new ConvolveOp(k); }