本文整理汇总了Java中java.awt.image.ConvolveOp.EDGE_NO_OP属性的典型用法代码示例。如果您正苦于以下问题:Java ConvolveOp.EDGE_NO_OP属性的具体用法?Java ConvolveOp.EDGE_NO_OP怎么用?Java ConvolveOp.EDGE_NO_OP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.image.ConvolveOp
的用法示例。
在下文中一共展示了ConvolveOp.EDGE_NO_OP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
@Override
public final BufferedImage apply(BufferedImage img) {
float[][] matrix = getMatrix();
float[] data = getKernelData(matrix);
if(normalize)
normalize(data);
scale(data);
if(isZero(data))
return new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
Kernel k = new Kernel(matrix[0].length, matrix.length, data);
ConvolveOp op = new ConvolveOp(k, ConvolveOp.EDGE_NO_OP, null);
BufferedImage img2 = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_INT_RGB);
img2.getGraphics().drawImage(img, 0, 0, null);
return op.filter(img2, null);
}
示例2: effect_blur
/**
* Blur the image
* @param amount
*/
public void effect_blur(int amount) { // TODO
int radius = amount;
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size * size];
for (int i = 0; i < data.length; i++) {
data[i] = weight;
}
Kernel kernel = new Kernel(size, size, data);
ConvolveOp op = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
image = op.filter(image, null);
}
示例3: main
public static void main(final String[] _args) {
String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv";
float[] convMatrix3x3 = new float[] {
0f,
-10f,
0f,
-10f,
41f,
-10f,
0f,
-10f,
0f
};
new JJMPEGPlayer("lab_6.alternate", fileName, convMatrix3x3){
@Override protected void processFrame(Graphics2D _gc, float[] _convMatrix3x3, BufferedImage _in, BufferedImage _out) {
java.awt.image.Kernel conv = new java.awt.image.Kernel(3, 3, _convMatrix3x3);
ConvolveOp convOp = new ConvolveOp(conv, ConvolveOp.EDGE_NO_OP, null);
convOp.filter(_in, _out);
}
};
}
示例4: blurImage
public static BufferedImage blurImage(BufferedImage image)
{
float ninth = 1.0f/9.0f;
float[] blurKernel = {
ninth, ninth, ninth,
ninth, ninth, ninth,
ninth, ninth, ninth
};
Map<RenderingHints.Key, Object> map = new HashMap<RenderingHints.Key, Object>();
map.put(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
map.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
map.put(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints hints = new RenderingHints(map);
BufferedImageOp op = new ConvolveOp(new Kernel(3, 3, blurKernel), ConvolveOp.EDGE_NO_OP, hints);
return op.filter(image, null);
}
示例5: lock
/**
* @param time
*/
public void lock(final int time) {
frame.getGlassPane().setVisible(false);
screen = createScreenShot();
frame.getGlassPane().setVisible(true);
if (screen != null) {
gray = ImageProvider.convertToGrayScale(screen);
final float data[] = { 0.0625f, 0.125f, 0.0625f, 0.125f, 0.25f, 0.125f, 0.0625f, 0.125f, 0.0625f };
final Kernel kernel = new Kernel(3, 3, data);
final ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
final BufferedImage dest = new BufferedImage(gray.getWidth(), gray.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
gray = convolve.filter(gray, dest);
frame.setGlassPane(this);
frame.getGlassPane().setVisible(true);
fadeIn(time);
}
}
示例6: getBlurFilter
public static ConvolveOp getBlurFilter(int radius) {
if (radius < 1) {
throw new IllegalArgumentException("Radius must be >= 1");
}
int size = radius * 2 + 1;
float weight = 1.0f / (size * size);
float[] data = new float[size * size];
for (int i = 0; i < data.length; i++) {
data[i] = weight;
}
Kernel kernel = new Kernel(size, size, data);
return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
}
示例7: processImage
/**
* Uses a blur filter on an image in an attempt to make it readable by the
* QRCodeReader.
*
* @param image
* the page in a BufferedImage object
* @return another BufferedImage object with the filters applied to it
*/
private BufferedImage processImage(BufferedImage image) {
// default: 3x3 filter for a 72 DPI image
double DEFAULT_SIZE = 9.0;
// calculate filtering matrix size based on the image resolution
int dimension = (int) Math.sqrt(DEFAULT_SIZE
/ (double) DEFAULT_RESOLUTION * RETAKE_RESOLUTION);
int size = dimension * dimension;
float[] matrix = new float[size];
for (int i = 0; i < size; i++)
matrix[i] = 1.0f / (float) size;
BufferedImageOp op = new ConvolveOp(new Kernel(dimension, dimension,
matrix), ConvolveOp.EDGE_NO_OP, null);
return op.filter(image, null);
}
示例8: getConvolveOp
private ConvolveOp getConvolveOp(int blurRadius, double dpiFactor) {
blurRadius = (int) (blurRadius * dpiFactor);
final int blurRadius2 = blurRadius * blurRadius;
final float blurRadius2F = blurRadius2;
// final float weight = (float) (1.0 / blurRadius2F / dpiFactor);
final float weight = (float) (1.0 / blurRadius2F);
final float[] elements = new float[blurRadius2];
for (int k = 0; k < blurRadius2; k++) {
elements[k] = weight;
}
final Kernel myKernel = new Kernel(blurRadius, blurRadius, elements);
// if EDGE_NO_OP is not selected, EDGE_ZERO_FILL is the default which
// creates a black border
return new ConvolveOp(myKernel, ConvolveOp.EDGE_NO_OP, null);
}
示例9: blurIt
public static BufferedImage blurIt(BufferedImage imSrc) {
// add some blurring
float data[] = { 0.0625f * 1f, 0.125f * 1f, 0.0625f * 1f, 0.125f * 1f,
0.25f * 1f, 0.125f * 1f, 0.0625f * 1f, 0.125f * 1f,
0.0625f * 1f };
Kernel kernel = new Kernel(3, 3, data);
ConvolveOp convolve = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP,
null);
int type = imSrc.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : imSrc
.getType();
BufferedImage imDest = new BufferedImage((imSrc.getWidth()),
imSrc.getHeight(), type);
convolve.filter(imSrc, imDest);
return imDest;
}
示例10: blur
/**
* Apply blurring to the generate image
*
* @param image The image to be blurred
*/
private void blur(BufferedImage image) {
float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
BufferedImage scratchImage = EffectUtil.getScratchImage();
for (int i = 0; i < blurPasses; i++) {
gaussianOp1.filter(image, scratchImage);
gaussianOp2.filter(scratchImage, image);
}
}
示例11: resize
private byte[] resize(byte[] bytes, int newSize, int operation, String imgType) {
if (bytes == null || WakaUtils.string.isEmpty(imgType) || newSize <= 0) {
throw new ZhhrUtilException("获取文件大小失败!入参为空");
}
Image image = new ImageIcon(bytes).getImage();
Image resizedImage = getResizedImage(image, newSize, operation);
// This code ensures that all the pixels in the image are loaded.
Image temp = new ImageIcon(resizedImage).getImage();
// Create the buffered image.
BufferedImage bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null), BufferedImage.TYPE_INT_RGB);
// Copy image to buffered image.
Graphics g = bufferedImage.createGraphics();
// Clear background and paint the image.
// g.setColor(Color.white);
g.fillRect(0, 0, temp.getWidth(null), temp.getHeight(null));
g.drawImage(temp, 0, 0, null);
g.dispose();
// Soften.
float softenFactor = 0.05f;
float[] softenArray = { 0, softenFactor, 0, softenFactor, 1 - (softenFactor * 4), softenFactor, 0, softenFactor, 0 };
Kernel kernel = new Kernel(3, 3, softenArray);
ConvolveOp cOp = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
bufferedImage = cOp.filter(bufferedImage, null);
// 输出
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ImageIO.write(bufferedImage, imgType, os);
return os.toByteArray();
} catch (IOException e) {
throw new ZhhrUtilException(e.getMessage(), e);
}
}
示例12: BlurLayerUI
public BlurLayerUI() {
float ninth = 1.0f / 9.0f;
float[] blurKernel = {
ninth, ninth, ninth,
ninth, ninth, ninth,
ninth, ninth, ninth
};
mOperation = new ConvolveOp(
new Kernel(3, 3, blurKernel),
ConvolveOp.EDGE_NO_OP, null);
}
示例13: setGaussianBlur
public static BufferedImage setGaussianBlur(BufferedImage originImg, int size) {
int mSize = size*size;
float[] elements = new float[mSize];
for (int i = 0; i < mSize; i++) {
elements[i] = 1.0f/mSize;
}
Kernel kernel = new Kernel(size, size, elements);
ConvolveOp cop = new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null);
int width = originImg.getWidth();
int height = originImg.getHeight();
float minSize = width < height ? width * 1.0f : height * 1.0f;
float scaleFactor = minSize <= 200 ? 1.0f : 200.0f / minSize;
AffineTransform transform =
AffineTransform.getScaleInstance(scaleFactor, scaleFactor);
AffineTransformOp aop = new AffineTransformOp(transform,
AffineTransformOp.TYPE_BILINEAR);
BufferedImage transImg = new BufferedImage(
(int)(width * scaleFactor), (int)(height * scaleFactor), originImg.getType());
aop.filter(originImg, transImg);
BufferedImage blurImg = new BufferedImage(
transImg.getWidth(), transImg.getHeight(), transImg.getType());
cop.filter(transImg, blurImg);
return blurImg;
}
示例14: setFilteredImage
/**
* Makes the image change from black to red, depending on the temperature of the heating element
*
* @param heatingElement
*/
private void setFilteredImage( HeatingElement heatingElement ) {
double temperature = heatingElement.getTemperature();
// double temperature = heatingElement.getIsEnabled() ? heatingElement.getTemperature() : 0;
BufferedImage newImg = baseImage;
ColorModel cm = newImg.getColorModel();
for ( int x = 0; x < newImg.getWidth(); x++ ) {
for ( int y = 0; y < newImg.getHeight(); y++ ) {
int rgb = newImg.getRGB( x, y );
int alpha = cm.getAlpha( rgb );
int red = Math.min( (int) temperature, 255 );
int green = 0;
int blue = 0;
int newRGB = alpha * 0x01000000 + red * 0x00010000 + green * 0x000000100 + blue * 0x00000001;
newImg.setRGB( x, y, newRGB );
}
}
// blur the coil as it gets hotter
float e = ( 1f / 32f ) * (float) ( temperature / 255f );
float f = ( 1f / 9f ) * (float) ( temperature / 255f );
float g = 1 - f - e;
float[] blurCoeffs = new float[]{
e, e, e, e, e,
e, f, f, f, e,
e, f, g, f, e,
e, f, f, f, e,
e, e, e, e, e,
};
Kernel blurKernel = new Kernel( 5, 5, blurCoeffs );
ConvolveOp blurOp = new ConvolveOp( blurKernel, ConvolveOp.EDGE_NO_OP, new RenderingHints( RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON ) );
newImg = blurOp.filter( newImg, null );
setImage( newImg );
setBoundsDirty();
repaint();
}
示例15: makeScreen
/**
* Metoda do robienia screenów gry.
*
* @param bWspX slickowa wspX myszki
* @param bWspY slickowa wspY myszki
*/
public static void makeScreen(int bWspX, int bWspY) {
try {
Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
double mouseX = MouseInfo.getPointerInfo().getLocation().getX() - bWspX;
double mouseY = MouseInfo.getPointerInfo().getLocation().getY() - bWspY;
Rectangle GAMEscreenRect = new Rectangle((int) mouseX, (int) mouseY, 1280, 720);
BufferedImage capture = new Robot().createScreenCapture(GAMEscreenRect);
float[] matrix = new float[400];
for (int i = 0; i < 400; i++) {
matrix[i] = 1.0f / 400.0f;
}
BufferedImageOp op = new ConvolveOp(new Kernel(20, 20, matrix), ConvolveOp.EDGE_NO_OP, null);
BufferedImage capture1 = new BufferedImage(1280, 720, BufferedImage.TYPE_INT_RGB);
nrScreena++;
ImageIO.write(op.filter(capture, capture1), "png", new File("graphic/menu/skrin" + nrScreena + ".png"));
if (nrScreena > 2) {
deleteScreen();
}
} catch (AWTException aWTException) {
System.out.println("Błąd AWT - makeScreen");
} catch (IOException iOException) {
System.out.println("Błąd IO - makeScreen");
}
}