java图像反色_java实现的图像反转、反色、滤波、水印、旋转等操作

该博客介绍了如何使用Java进行图像处理,包括图像反色、滤波和添加水印的操作。通过示例代码展示了如何读取图像、调整亮度、翻转图像以及应用水印到图像上,提供了详细的步骤和代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import com.sun.image.codec.jpeg.JPEGCodec;

import com.sun.image.codec.jpeg.JPEGImageDecoder;

import java.io.FileInputStream;

import java.io.BufferedReader;

import java.awt.image.BufferedImage;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.io.IOException;

import javax.imageio.*;

import java.awt.Image;

import java.awt.AlphaComposite;

import java.io.File;

import java.awt.Color;

import java.util.Arrays;

import java.awt.geom.AffineTransform;

//import java.lang.reflect.Array;

import java.awt.image.AffineTransformOp;

public class test{

public static int getBrighter(int red,int gre,int

blu , int flag){

red += flag;

gre += flag;

blu += flag;

if(red > 255)

red = 255;

if(gre > 255)

gre = 255;

if(blu > 255)

blu = 255;

if(red < 0) red

= 0;

if(gre < 0) gre

= 0;

if(blu < 0) blu

= 0;

return new

Color(red,gre,blu).getRGB();

}

public static void

main(String[] args) {

BufferedImage Source_image =

null;

BufferedImage Water_image =

null;

BufferedImage New_image =

null;

try{

FileInputStream

in = new FileInputStream("c:/temp/noise.jpg");//ophama97.jpg要装入的图片 JPEGImageDecoder

decoder = JPEGCodec.createJPEGDecoder(in); Source_image

=

decoder.decodeAsBufferedImage();//取的bufferedimage 对象 //水印文件 File _filebiao = new

File("c:/temp/water.jpg"); Image src_biao =

ImageIO.read(_filebiao); int wideth_biao =

src_biao.getWidth(null); int height_biao =

src_biao.getHeight(null); int height =

Source_image.getHeight();

int

width = Source_image.getWidth();

//Source_image.getco

New_image =

new BufferedImage(256,256,1);

//New_image =

Source_image;

int color_now

= 0;

int[]

intColor = new int[9];

for(int i = 1

; i < width;i++){

for(int

j = 1 ; j < height;j++){

//int color_now = Source_image.getRGB(i,j); //从x,y读颜色

//System.out.println(color_now);

//图片加亮

//int

newColor = getBrighter(red,gre,blu,100);

//Source_image.setRGB(i,j,newColor);//向x,y写颜色color_now

//System.out.println(color_now);

//上下翻转

//New_image.setRGB(i,height

- j,color_now);//向x,y写颜色color_now

//左右镜像

//New_image.setRGB(width

- i,j,color_now);//向x,y写颜色color_now

//反色

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值