十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
//运行以下程序即可
10多年的铜仁网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整铜仁建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“铜仁网站设计”,“铜仁网站推广”以来,每个客户项目都认真落实执行。
public class ImageInit {
BufferedImage image;
private int iw, ih;
private int[] pixels;
public ImageInit(BufferedImage image) {
this.image = image;
iw = image.getWidth();
ih = image.getHeight();
pixels = new int[iw * ih];
}
public BufferedImage changeGrey() {
PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih,
pixels, 0, iw);
try {
pg.grabPixels();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 设定二值化的域值,默认值为100
int grey = 100;
// 对余圆图像进行二值化处理,Alpha值保持不变
ColorModel cm = ColorModel.getRGBdefault();
for (int i = 0; i iw * ih; i++) {
int red, green, blue;
int alpha = cm.getAlpha(pixels[i]);
if (cm.getRed(pixels[i]) grey) {
red = 255;
} else {
red = 0;
}
if (cm.getGreen(pixels[i]) grey) {
green = 255;
} else {
green = 0;
}
if (cm.getBlue(pixels[i]) grey) {
blue = 255;
} else {
blue = 0;
}
pixels[i] = alpha 24 | red 16 | green 8 | blue; // 通过移位重新构成某一点像素的RGB值
}
// 将数组中的象素产生一个图像
Image tempImg = Toolkit.getDefaultToolkit().createImage(
new MemoryImageSource(iw, ih, pixels, 0, iw));
image = new BufferedImage(tempImg.getWidth(null),
tempImg.getHeight(null), BufferedImage.TYPE_INT_BGR);
image.createGraphics().drawImage(tempImg, 0, 0, null);
return image;
}
public BufferedImage getMedian() {
PixelGrabber pg = new PixelGrabber(image.getSource(), 0, 0, iw, ih,
pixels, 0, iw);
try {
pg.grabPixels();
} catch (InterruptedException e) {
e.printStackTrace();
}
// 对图像进行中值滤波,Alpha值保持不变
ColorModel cm = ColorModel.getRGBdefault();
for (int i = 1; i ih - 1; i++) {
for (int j = 1; j iw - 1; j++) {
int red, green, blue;
int alpha = cm.getAlpha(pixels[i * iw + j]);
// int red2 = cm.getRed(pixels[(i - 1) * iw + j]);
int red4 = cm.getRed(pixels[i * iw + j - 1]);
int red5 行毁袜= cm.getRed(pixels[i * iw + j]);
int red6 = cm.getRed(pixels[i * iw + j + 1]);
// 档激int red8 = cm.getRed(pixels[(i + 1) * iw + j]);
// 水平方向进行中值滤波
if (red4 = red5) {
if (red5 = red6) {
red = red5;
} else {
if (red4 = red6) {
red = red6;
} else {
red = red4;
}
}
} else {
if (red4 red6) {
red = red4;
} else {
if (red5 red6) {
red = red6;
} else {
red = red5;
}
}
}
int green4 = cm.getGreen(pixels[i * iw + j - 1]);
int green5 = cm.getGreen(pixels[i * iw + j]);
int green6 = cm.getGreen(pixels[i * iw + j + 1]);
// 水平方向进行中值滤波
if (green4 = green5) {
if (green5 = green6) {
green = green5;
} else {
if (green4 = green6) {
green = green6;
} else {
green = green4;
}
}
} else {
if (green4 green6) {
green = green4;
} else {
if (green5 green6) {
green = green6;
} else {
green = green5;
}
}
}
// int blue2 = cm.getBlue(pixels[(i - 1) * iw + j]);
int blue4 = cm.getBlue(pixels[i * iw + j - 1]);
int blue5 = cm.getBlue(pixels[i * iw + j]);
int blue6 = cm.getBlue(pixels[i * iw + j + 1]);
// int blue8 = cm.getBlue(pixels[(i + 1) * iw + j]);
// 水平方向进行中值滤波
if (blue4 = blue5) {
if (blue5 = blue6) {
blue = blue5;
} else {
if (blue4 = blue6) {
blue = blue6;
} else {
blue = blue4;
}
}
} else {
if (blue4 blue6) {
blue = blue4;
} else {
if (blue5 blue6) {
blue = blue6;
} else {
blue = blue5;
}
}
}
pixels[i * iw + j] = alpha 24 | red 16 | green 8
| blue;
}
}
// 将数组中的象素产生一个图像
Image tempImg = Toolkit.getDefaultToolkit().createImage(
new MemoryImageSource(iw, ih, pixels, 0, iw));
image = new BufferedImage(tempImg.getWidth(null),
tempImg.getHeight(null), BufferedImage.TYPE_INT_BGR);
image.createGraphics().drawImage(tempImg, 0, 0, null);
return image;
}
public BufferedImage getGrey() {
ColorConvertOp ccp = new ColorConvertOp(
ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
return image = ccp.filter(image, null);
}
// Brighten using a linear formula that increases all color values
public BufferedImage getBrighten() {
RescaleOp rop = new RescaleOp(1.25f, 0, null);
return image = rop.filter(image, null);
}
// Blur by "convolving" the image with a matrix
public BufferedImage getBlur() {
float[] data = { .1111f, .1111f, .1111f, .1111f, .1111f, .1111f,
.1111f, .1111f, .1111f, };
ConvolveOp cop = new ConvolveOp(new Kernel(3, 3, data));
return image = cop.filter(image, null);
}
// Sharpen by using a different matrix
public BufferedImage getSharpen() {
float[] data = { 0.0f, -0.75f, 0.0f, -0.75f, 4.0f, -0.75f, 0.0f,
-0.75f, 0.0f };
ConvolveOp cop = new ConvolveOp(new Kernel(3, 3, data));
return image = cop.filter(image, null);
}
// 11) Rotate the image 180 degrees about its center point
public BufferedImage getRotate() {
AffineTransformOp atop = new AffineTransformOp(
AffineTransform.getRotateInstance(Math.PI,
image.getWidth() / 2, image.getHeight() / 2),
AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
return image = atop.filter(image, null);
}
public BufferedImage getProcessedImg() {
return image;
}
public static void main(String[] args) throws IOException {
String filePath="F:/k7qp5.png";
FileInputStream fin = new FileInputStream(filePath);
BufferedImage bi = ImageIO.read(fin);
ImageInit flt = new ImageInit(bi);
flt.changeGrey();
flt.getGrey();
flt.getBrighten();
bi = flt.getProcessedImg();
String pname = filePath.substring(0, filePath.lastIndexOf("."));
File file = new File(pname + ".jpg");
ImageIO.write(bi, "jpg", file);
}
}
使用软件:PS CC版
水印不可能批量去除的,因为水印所在的每个图的位置不一样,而且就算位置一样,图像背景和所含内容也不一样,所以只能单个去除,以下提供使用PS快速去除水印的多种方法:
1、使用仿制图章工具去水印
这是比较常用的方法。具体的操作是,选取仿制图章工具,按住Alt键,在无文字区域点击相似的色彩或图案采样, 然后在孙兄水印区域拖动鼠标复制以复盖水印。
2、使用修补工具去水印
如果图片的背景色彩或图案比较一致,使用修补工具就比较方便。具体的操作是,选取修补工具,在公共栏中选择修补项为“源”,关闭“透明”选项。
3、相似图形(或图案)
某些情况下,拆慎框选无文字区域的相似图形(或图案),按Ctrl+j键将其复制成新的图层,再利用变形工具将其变形,直接用以覆盖水印会更为快捷。
4、填充的内容识别(智能填充)等工具来修补
办法多种,还可用画笔、印章、涂摸、橡擦、填充等根旅凯敬据不同情况可以一一尝试。
带有水印的图片,是合成过的
所以,用档模肆ps修补简单易用,如果码喊用java去实现类似ps的功能,难度可想而知,建议换种行轿思路考虑这个问题