图像处理数字水印.doc
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
从而remove掉多余的像素。
混合轧花的方法为embossImageO主要是简单的像素填充,布尔变量主要是用来控 制是凹轧花
还是凸轧花效果。所有对文字图像的处理和轧花效果的处理封装在BitBItFilter一个 类中.
程序效果如下:
[java] view plaincopy
package com•gloomyfish•zoom•study;
import java•awt.image.Bufferedlmage;
import com.process.blur.study.AbstractBufferedlmageOp;
public class BitBltFilter extends AbstractBufferedlmageOp (
// raster operation - bit block transfer•
// 1975 for the Smalltalk-72 system. For the Smalltalk-74 system
10.private boolean isTop = true;
11.
11./**
12.* left - top skeleton or right - bottom•
13.*
58.
int[] outPixels = new int[width*height];
59.
getRGB( src> 0,饥width, height, inPixels );
60.
int index = 0;
61.
int index2 = 0;
62.
// initialization outPixels
.tg2=(outPixels[index]>>8) & 0xff;
.tb2=outPixels[index] & 0xff;
•
.if(tr2 == tr && tg == tg2 && tb == tb2) (
.outPixels[index] = (255 << 24) | (255 << 16) |
至黑白文字图片完全copy到单色白板中。
3.重复上面操作,唯一不同的,将白板像素移动一个像素为,以后开始填充
4.分别将两张位图块迁移图片与原黑白文字图片像素完成一个或操作,则得到左 上和右下
的文字骨架。
5.将两个文字骨架的像素填充到目标彩色图片中,即得到轧花效果的图片
根据输入参数不同,还可得到雕刻效果图片。
int dh = dest.getHeight();
78.
tg = (inPixels[isTop?index:index2] >> 8) & 0xff;
79.
tb = inPixels[isTop?index:index2] & 0xff;
80.
outPixels[isTop?index2:index] = (ta << 24) | (tr <<
81.
)I (255 « 8) | 255;
. }
•}
. }
•}
.setRGB( destlmage, 0, 0, width, height, outPixels );
• }
./**
*
.* @paramsrc
•*@paramdest
•*@paramcolorinverse-mustbesettedhere!!!
74.
index = row * width + col;
75.
index2 = (row-1) * width + (col-1);
76.
ta = (inPixels[isTop?index:index2] >> 24) & 0xff;
77.
tr = (inPixels[isTop?index:index2] >> 16) & 0xff;
tb = inPixels[isTop?index:index2] & Oxff;
outPixels[isTop?index2:index] = (ta « 24) | (tr« 16) | (tg « 8) | tb;
)
}
布尔变量isTop决定是否填充单色白板位移(Offset)是零还是一。
获取一个像素宽度骨架的方法为processonePixelWidth()主要是利用文字图片是一 个二值图像,
67.
<< 8) | 255;
}
68.
}
69.
70.
// one pixel transfer
71.
for(int row=l; row<height; row++) (
72.
int ta = 0^ tr = 0, tg = 0^ tb = 0;
73.
for(int col=l; col<width; col++) (
63.
for(int row=0; row<height; row++) (
64.
for(int col=0; col<width; col++) (
65.
index = row * width + col;
66.
outPixels[index] = (255 << 24) | (255 << 16) | (255
16) | (tg « 8) | tb;
}
82.
}
83.
setRGB( dest,0, 0,width, height, outPixels );
84.
return dest;
85.
}
86.
87.
/**
88.
*
89.
* @param width
90.
* @param height
91.
* @param inPixels
.*/
. private void embossImage(BufferedImage src, Bufferedlmage dest, boolean colorinverse)
int width = src.getWidth();
int height = src.getHeight();
int dw = dest.getWidth();
// now get one pixel data int index = 0;
for(int row=0; row<height; row++) (
int ta = 0?tr = 0?tg = 0?tb = 0;
int ta2 =0, tr2 = 0, tg2 = 0, tb2 = 0; for(int col=0; col<width;
(255 << 8) | 255;
.} else (
,if(tr2 < 5 && tg2 < 5 && tb2 < 5) {
・outPixels[index] = (ta2 << 24) | (tr2 << 16 )I (tg2 « 8) | tb2;
.} else {
.outPixels[index] = (255 << 24) | (255 << 16
tomimage);
43.
44•// emboss now
45.embosslmage(toplmagejtargetlmage, true);
46.embosslmage(buttomlmagejtargetlmage^ false);
47.}
48.
48.Βιβλιοθήκη BaiduOverride
49.public Bufferedlmagefilter(Bufferedlmagesrc, Bufferedlmage des
index = row * width + ta = (inPixels[index] tr = (inPixelsfindex] tg = (inPixelsfindex]tb = inPixelsfindex] & 0xff;
.ta2=(outPixels[index]>>24)&0xff;
.tr2=(outPixels[index]>>16)&Oxff;
34.int[] inPixels = new int[width*height];
35.int[] outPixels = new int[width*height];
38•getRGB( textlmage^ 0, width, height, inPixels );
39.getRGB( toplmage^饥width, height, outPixels );
40.processonePixelWidth(widths height, inPixels> outPixels, top Image);
41.getRGB( buttomlmage^ 0?0, width, height, outPixels );
42•processonePixelWidth(widths height, inPixels> outPixels, but
实现原理
主要是利用位图块迁移算法,首先提取文字骨架,宽度为一个像素。然后将提取的
骨架,按
照一定的像素值填充到目标图像中即可。关于位图块迁移算法说明请看这里:
http://en.wikipedia.org/wiki/Bit_blit
程序思路:
1.首先创建两张白板的单色位图,读入黑白文字图片,
2.移动一个像素位开始读取文字图片中的像素,将每个对应像素与白板单色图片 叠加,直
92.
* @param outPixels
93.
* @param destlmage
94.
*/
95.
private void processonePixelWidth(int width, int height, int[] i
nPixels, int[] outPixels, Bufferedlmage destlmage) {
25•*@paramtargetimage
26.*/
27.public void emboss(Bufferedlmage textimage, Bufferedlmage target Image) {
28.// BitBltFilter filter = new BitBltFilter();
29.Bufferedlmage topImage = filter(textImage^ null);
index2 = (row-1) * width + (col-1);
ta = (inPixels[isTop?index:index2] » 24) & Oxff;
tr = (inPixels[isTop?index:index2] » 16) & Oxff;
tg = (inPixels[isTop?index:index2] » 8) & Oxff;
15•* @param isTop
16.*/
17.public void setTop(boolean isTop) (
18.this.isTop = isTop;
19.}
20.
20./**
21.*blendthe pixels and get the final output image
22.*
23.*@paramtextimage
30.setTop(false);
31.Bufferedlmage buttomlmage = filter(textImage^ null);
32.
32.int width = textimage.getWidth();
33.int height = textImage•getHeight();
35.
关键代码解释:
实现位图块迁移算法的代码如下:
// one pixel transfer
for(introw=1; row<height; row++) (
intta = 0, tr = 0, tg = 0, tb = 0;
for(intcol=1; cokwidth; col++) (
index = row * width + col;
t) {
50.int width = src.getWidth();
51.int height = src.getHeight();
53.
52.if ( dest == null )
55.
dest = createCompatibleDestImage(src>null);
56.
57.
int[] inPixels = new int[width*height];
图像处理之简单数字水印-文字轧花效果
分类:图像处理2012-03-09 23:18 1594人阅读评论(0)收藏举报 图像处理filternulljcomponentinitializationimage
图像处理之文字轧花效果•简单数字水印@ gloomyfish
首先看一下效果,左边是一张黑白的文字图像,右边是混合之后的数字水印效果
混合轧花的方法为embossImageO主要是简单的像素填充,布尔变量主要是用来控 制是凹轧花
还是凸轧花效果。所有对文字图像的处理和轧花效果的处理封装在BitBItFilter一个 类中.
程序效果如下:
[java] view plaincopy
package com•gloomyfish•zoom•study;
import java•awt.image.Bufferedlmage;
import com.process.blur.study.AbstractBufferedlmageOp;
public class BitBltFilter extends AbstractBufferedlmageOp (
// raster operation - bit block transfer•
// 1975 for the Smalltalk-72 system. For the Smalltalk-74 system
10.private boolean isTop = true;
11.
11./**
12.* left - top skeleton or right - bottom•
13.*
58.
int[] outPixels = new int[width*height];
59.
getRGB( src> 0,饥width, height, inPixels );
60.
int index = 0;
61.
int index2 = 0;
62.
// initialization outPixels
.tg2=(outPixels[index]>>8) & 0xff;
.tb2=outPixels[index] & 0xff;
•
.if(tr2 == tr && tg == tg2 && tb == tb2) (
.outPixels[index] = (255 << 24) | (255 << 16) |
至黑白文字图片完全copy到单色白板中。
3.重复上面操作,唯一不同的,将白板像素移动一个像素为,以后开始填充
4.分别将两张位图块迁移图片与原黑白文字图片像素完成一个或操作,则得到左 上和右下
的文字骨架。
5.将两个文字骨架的像素填充到目标彩色图片中,即得到轧花效果的图片
根据输入参数不同,还可得到雕刻效果图片。
int dh = dest.getHeight();
78.
tg = (inPixels[isTop?index:index2] >> 8) & 0xff;
79.
tb = inPixels[isTop?index:index2] & 0xff;
80.
outPixels[isTop?index2:index] = (ta << 24) | (tr <<
81.
)I (255 « 8) | 255;
. }
•}
. }
•}
.setRGB( destlmage, 0, 0, width, height, outPixels );
• }
./**
*
.* @paramsrc
•*@paramdest
•*@paramcolorinverse-mustbesettedhere!!!
74.
index = row * width + col;
75.
index2 = (row-1) * width + (col-1);
76.
ta = (inPixels[isTop?index:index2] >> 24) & 0xff;
77.
tr = (inPixels[isTop?index:index2] >> 16) & 0xff;
tb = inPixels[isTop?index:index2] & Oxff;
outPixels[isTop?index2:index] = (ta « 24) | (tr« 16) | (tg « 8) | tb;
)
}
布尔变量isTop决定是否填充单色白板位移(Offset)是零还是一。
获取一个像素宽度骨架的方法为processonePixelWidth()主要是利用文字图片是一 个二值图像,
67.
<< 8) | 255;
}
68.
}
69.
70.
// one pixel transfer
71.
for(int row=l; row<height; row++) (
72.
int ta = 0^ tr = 0, tg = 0^ tb = 0;
73.
for(int col=l; col<width; col++) (
63.
for(int row=0; row<height; row++) (
64.
for(int col=0; col<width; col++) (
65.
index = row * width + col;
66.
outPixels[index] = (255 << 24) | (255 << 16) | (255
16) | (tg « 8) | tb;
}
82.
}
83.
setRGB( dest,0, 0,width, height, outPixels );
84.
return dest;
85.
}
86.
87.
/**
88.
*
89.
* @param width
90.
* @param height
91.
* @param inPixels
.*/
. private void embossImage(BufferedImage src, Bufferedlmage dest, boolean colorinverse)
int width = src.getWidth();
int height = src.getHeight();
int dw = dest.getWidth();
// now get one pixel data int index = 0;
for(int row=0; row<height; row++) (
int ta = 0?tr = 0?tg = 0?tb = 0;
int ta2 =0, tr2 = 0, tg2 = 0, tb2 = 0; for(int col=0; col<width;
(255 << 8) | 255;
.} else (
,if(tr2 < 5 && tg2 < 5 && tb2 < 5) {
・outPixels[index] = (ta2 << 24) | (tr2 << 16 )I (tg2 « 8) | tb2;
.} else {
.outPixels[index] = (255 << 24) | (255 << 16
tomimage);
43.
44•// emboss now
45.embosslmage(toplmagejtargetlmage, true);
46.embosslmage(buttomlmagejtargetlmage^ false);
47.}
48.
48.Βιβλιοθήκη BaiduOverride
49.public Bufferedlmagefilter(Bufferedlmagesrc, Bufferedlmage des
index = row * width + ta = (inPixels[index] tr = (inPixelsfindex] tg = (inPixelsfindex]tb = inPixelsfindex] & 0xff;
.ta2=(outPixels[index]>>24)&0xff;
.tr2=(outPixels[index]>>16)&Oxff;
34.int[] inPixels = new int[width*height];
35.int[] outPixels = new int[width*height];
38•getRGB( textlmage^ 0, width, height, inPixels );
39.getRGB( toplmage^饥width, height, outPixels );
40.processonePixelWidth(widths height, inPixels> outPixels, top Image);
41.getRGB( buttomlmage^ 0?0, width, height, outPixels );
42•processonePixelWidth(widths height, inPixels> outPixels, but
实现原理
主要是利用位图块迁移算法,首先提取文字骨架,宽度为一个像素。然后将提取的
骨架,按
照一定的像素值填充到目标图像中即可。关于位图块迁移算法说明请看这里:
http://en.wikipedia.org/wiki/Bit_blit
程序思路:
1.首先创建两张白板的单色位图,读入黑白文字图片,
2.移动一个像素位开始读取文字图片中的像素,将每个对应像素与白板单色图片 叠加,直
92.
* @param outPixels
93.
* @param destlmage
94.
*/
95.
private void processonePixelWidth(int width, int height, int[] i
nPixels, int[] outPixels, Bufferedlmage destlmage) {
25•*@paramtargetimage
26.*/
27.public void emboss(Bufferedlmage textimage, Bufferedlmage target Image) {
28.// BitBltFilter filter = new BitBltFilter();
29.Bufferedlmage topImage = filter(textImage^ null);
index2 = (row-1) * width + (col-1);
ta = (inPixels[isTop?index:index2] » 24) & Oxff;
tr = (inPixels[isTop?index:index2] » 16) & Oxff;
tg = (inPixels[isTop?index:index2] » 8) & Oxff;
15•* @param isTop
16.*/
17.public void setTop(boolean isTop) (
18.this.isTop = isTop;
19.}
20.
20./**
21.*blendthe pixels and get the final output image
22.*
23.*@paramtextimage
30.setTop(false);
31.Bufferedlmage buttomlmage = filter(textImage^ null);
32.
32.int width = textimage.getWidth();
33.int height = textImage•getHeight();
35.
关键代码解释:
实现位图块迁移算法的代码如下:
// one pixel transfer
for(introw=1; row<height; row++) (
intta = 0, tr = 0, tg = 0, tb = 0;
for(intcol=1; cokwidth; col++) (
index = row * width + col;
t) {
50.int width = src.getWidth();
51.int height = src.getHeight();
53.
52.if ( dest == null )
55.
dest = createCompatibleDestImage(src>null);
56.
57.
int[] inPixels = new int[width*height];
图像处理之简单数字水印-文字轧花效果
分类:图像处理2012-03-09 23:18 1594人阅读评论(0)收藏举报 图像处理filternulljcomponentinitializationimage
图像处理之文字轧花效果•简单数字水印@ gloomyfish
首先看一下效果,左边是一张黑白的文字图像,右边是混合之后的数字水印效果