随机画点

@param image 图片
430168
private void drawPoint(BufferedImage image) {
        if (this.pointPower == -1) {
            return;
        }
        Random r = new Random();
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        int max = this.w * this.h / this.pointPower;
        for (int i = 0; i < max; i++) {
            int x = r.nextInt(w);
            int y = r.nextInt(h);
            g2.setStroke(new BasicStroke(1.5F));
            g2.setColor(this.randomColor());
            g2.drawOval(x, y, 1, 1);
        }
        g2.dispose();
    }
1097555
public void performTracking( T image ) {
		if( image.width != imageWidth || image.height != imageHeight )
			throw new IllegalArgumentException("Tracking image size is not the same as " +
					"input image. Expected "+imageWidth+" x "+imageHeight);
		updateTrackLocation(image);
		if( interp_factor != 0 )
			performLearning(image);
	}
337511
private BufferedImage create_BACKGROUND_Image(final int WIDTH, BufferedImage image) {
        if (WIDTH <= 0) {
            return null;
        }
        if (image == null) {
            image = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
        }
        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        switch (getFrameType()) {
            case SQUARE:
                BACKGROUND_FACTORY.createLinearBackground(WIDTH, WIDTH, getBackgroundColor(), getCustomBackground(), getModel().getTextureColor(), image);
                break;
            case ROUND:

            default:
                BACKGROUND_FACTORY.createRadialBackground(WIDTH, getBackgroundColor(), getCustomBackground(), getModel().getTextureColor(), image);
                break;
        }
        G2.dispose();

        return image;
    }
1234852
public CalculusBuilder analyze(ImageView image) {

        if(image == null)
            throw new IllegalArgumentException("Image must not be null");

        mImage = Utils.getBitmapFromImageView(image);

        return new CalculusBuilder(mImage);
    }
880941
public void setImage(final Image image) {
		LinkModel model = getOrCreateComponentModel();
		model.image = image;
		model.imageUrl = null;
	}
1206235
function(image) {
        if (!this.isActive())
            throw "Trying to set image of texture that isn't active";
        this.width = image.width;
        this.height = image.height;
        this.size = image.width * image.height;
        this.powerOfTwo = !(
            Math.log(image.width) / Math.LN2 !==
                Math.floor(Math.log(image.width) / Math.LN2) ||
            Math.log(image.height) / Math.LN2 !==
                Math.floor(Math.log(image.height) / Math.LN2)
        );
        var gl = this.gl;
        gl.texImage2D(
            gl.TEXTURE_2D,
            0,
            gl.RGBA,
            gl.RGBA,
            gl.UNSIGNED_BYTE,
            image
        );
    }
214618
public void setData(BufferedImage image, String imageFormat)
			throws IOException {
		setData(image, imageFormat, null);
	}
759428
private void processSwatch(Bitmap image) {
        final Map<Integer, Integer> colorHistogram = processLuminanceData(image);
        extractFgBgData(colorHistogram);

        // Two-decimal digits of precision for the contrast ratio
        mContrastRatio = Math.round(
                ContrastUtils.calculateContrastRatio(mBackgroundLuminance, mForegroundLuminance)
                * 100.0d) / 100.0d;
    }
809124
public INDArray toRaveledTensor(BufferedImage image) {
        try {
            image = scalingIfNeed(image, false);
            return toINDArrayBGR(image).ravel();
        } catch (Exception e) {
            throw new RuntimeException("Unable to load image", e);
        }
    }
302217
public void setIcon(Image image) {

        m_iconPanel.setVisible(true);
        if (image == null) {
            return;
        }
        m_iconPanel.setWidget(image);
    }
803383
public static BufferedImage toBufferedImage(Image image, String imageType) {
		BufferedImage bufferedImage;
		if (false == imageType.equalsIgnoreCase(IMAGE_TYPE_PNG)) {
			// 当目标为非PNG类图片时，源图片统一转换为RGB格式
			if (image instanceof BufferedImage) {
				bufferedImage = (BufferedImage) image;
				if (BufferedImage.TYPE_INT_RGB != bufferedImage.getType()) {
					bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
				}
			} else {
				bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
			}
		} else {
			bufferedImage = toBufferedImage(image);
		}
		return bufferedImage;
	}
272866
public static int[] getRGB(BufferedImage image) {
		int[] pixels = getRGBArray(image);
		getRGB(image, pixels);
		return pixels;
	}
1143133
private String drawString(BufferedImage image) {
        Random r = new Random();
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        // 记录生成的文本
        StringBuilder sb = new StringBuilder();
        // 向图片中画指定个数字符
        for (int i = 0; i < this.textLength; i++) {
            String s = randomChar() + "";
            sb.append(s);
            // 字符的x坐标在[minX,maxX]范围内
            int cw = this.w / this.textLength;//每个字符占的宽度
            int minX = cw * i;
            int maxX = minX + cw * 2 / 3;
            int x = r.nextInt(maxX - minX + 1) + minX;
            //字符的y坐标在[minY,maxY]范围内
            Font font = randomFont();
            int minY = this.h * font.getSize() / 48;
            int maxY = this.h * font.getSize() * 3 / 80;
            minY = minY >= this.h ? this.h / 2 : minY;
            maxY = maxY >= this.h ? this.h * 9 / 10 : maxY;
            int y = r.nextInt(maxY - minY + 1) + minY;
            //字符旋转度数在[0,360']范围内
//            double rotate = Math.toRadians(30);//转换成theta值
//            g2.rotate(rotate, x + 12, y + 12);
            g2.setFont(font);
            g2.setColor(randomColor());
            g2.drawString(s, x, y);
        }
        return sb.toString();
    }
1035898
public static BufferedImage copyImage(BufferedImage image)
    {
        final BufferedImage copy = createImage(image.getWidth(),
                                               image.getHeight(),
                                               image.getColorModel().getTransparency());
        final Graphics2D g = copy.createGraphics();
        g.setComposite(AlphaComposite.Src);
        g.drawImage(image, 0, 0, null);
        g.dispose();
        return copy;
    }
602654
public void setImageUI(final BufferedImage image) {
		BoofSwingUtil.invokeNowOrLater(() -> {
			repaintJustImage(ImagePanel.this.img,adjustmentGUI);
			ImagePanel.this.img = image;
			repaintJustImage(ImagePanel.this.img,adjustmentGUI);
		});
	}
1164649
public static void saveImage(BufferedImage image, OutputStream output) throws IOException
    {
        ImageIO.write(image, "png", output);
    }
925753
public static byte[] bufferedImageToJPGByteArray(BufferedImage image) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ImageIO.write(image, "jpg", baos);
            //baos.flush();
            byte[] imageInByte = baos.toByteArray();
            //baos.close();
            return imageInByte;
        } catch (IOException ex) {
            Logger.getLogger(PHATImageUtils.class.getName()).log(Level.SEVERE, "bufferedImageToByteArray", ex);
        }
        return null;
    }