图像处理数字水印doc文档格式.docx
- 文档编号:16976664
- 上传时间:2022-11-27
- 格式:DOCX
- 页数:14
- 大小:74.21KB
图像处理数字水印doc文档格式.docx
《图像处理数字水印doc文档格式.docx》由会员分享,可在线阅读,更多相关《图像处理数字水印doc文档格式.docx(14页珍藏版)》请在冰豆网上搜索。
ta=(inPixels[isTop?
index:
index2]»
24)&
Oxff;
tr=(inPixels[isTop?
16)&
tg=(inPixels[isTop?
8)&
tb=inPixels[isTop?
index2]&
outPixels[isTop?
index2:
index]=(ta«
24)|(tr«
16)|(tg«
8)|tb;
)
}
布尔变量isTop决定是否填充单色白板位移(Offset)是零还是一。
获取一个像素宽度骨架的方法为processonePixelWidth()主要是利用文字图片是一个二值图像,
从而remove掉多余的像素。
混合轧花的方法为embossImageO主要是简单的像素填充,布尔变量主要是用来控制是凹轧花
还是凸轧花效果。
所有对文字图像的处理和轧花效果的处理封装在BitBItFilter一个类中.
程序效果如下:
位图块位移算法实现完全源代码如下:
[java]viewplaincopy
1.
2.
3.
4.
5.
6.
7.
8.
9.
packagecom•gloomyfish•zoom•study;
importjava•awt.image.Bufferedlmage;
importcom.process.blur.study.AbstractBufferedlmageOp;
publicclassBitBltFilterextendsAbstractBufferedlmageOp(
//rasteroperation-bitblocktransfer•
//1975fortheSmalltalk-72system.FortheSmalltalk-74system
10.privatebooleanisTop=true;
11.
11./**
12.*left-topskeletonorright-bottom•
13.*
15•*@paramisTop
16.*/
17.publicvoidsetTop(booleanisTop)(
18.this.isTop=isTop;
19.}
20.
20./**
21.*blendthepixelsandgetthefinaloutputimage
22.*
23.*@paramtextimage
25•*@paramtargetimage
26.*/
27.publicvoidemboss(Bufferedlmagetextimage,BufferedlmagetargetImage){
28.//BitBltFilterfilter=newBitBltFilter();
29.BufferedlmagetopImage=filter(textImage^null);
30.setTop(false);
31.Bufferedlmagebuttomlmage=filter(textImage^null);
32.
32.intwidth=textimage.getWidth();
33.intheight=textImage•getHeight();
35.
34.int[]inPixels=newint[width*height];
35.int[]outPixels=newint[width*height];
38•getRGB(textlmage^0,width,height,inPixels);
39.getRGB(toplmage^饥width,height,outPixels);
40.processonePixelWidth(widthsheight,inPixels>
outPixels,topImage);
41.getRGB(buttomlmage^0?
0,width,height,outPixels);
42•processonePixelWidth(widthsheight,inPixels>
outPixels,but
tomimage);
43.
44•//embossnow
45.embosslmage(toplmagejtargetlmage,true);
46.embosslmage(buttomlmagejtargetlmage^false);
47.}
48.
48.^Override
49.publicBufferedlmagefilter(Bufferedlmagesrc,Bufferedlmagedes
t){
50.intwidth=src.getWidth();
51.intheight=src.getHeight();
53.
52.if(dest==null)
55.
dest=createCompatibleDestImage(src>
null);
56.
57.
int[]inPixels=newint[width*height];
58.
int[]outPixels=newint[width*height];
59.
getRGB(src>
0,饥width,height,inPixels);
60.
intindex=0;
61.
intindex2=0;
62.
//initializationoutPixels
63.
for(introw=0;
64.
for(intcol=0;
col<
width;
65.
66.
outPixels[index]=(255<
<
24)|(255<
16)|(255
67.
8)|255;
68.
69.
70.
71.
for(introw=l;
72.
intta=0^tr=0,tg=0^tb=0;
73.
for(intcol=l;
74.
75.
76.
index2]>
>
0xff;
77.
78.
79.
80.
index]=(ta<
24)|(tr<
81.
16)|(tg«
82.
83.
setRGB(dest,0,0,width,height,outPixels);
84.
returndest;
85.
86.
87.
/**
88.
*
89.
*@paramwidth
90.
*@paramheight
91.
*@paraminPixels
92.
*@paramoutPixels
93.
*@paramdestlmage
94.
*/
95.
privatevoidprocessonePixelWidth(intwidth,intheight,int[]i
nPixels,int[]outPixels,Bufferedlmagedestlmage){
//nowgetonepixeldataintindex=0;
intta=0?
tr=0?
tg=0?
tb=0;
col++)(col;
0xff;
intta2=0,tr2=0,tg2=0,tb2=0;
for(intcol=0;
index=row*width+ta=(inPixels[index]tr=(inPixelsfindex]tg=(inPixelsfindex]tb=inPixelsfindex]&
.ta2=(outPixels[index]>
.tr2=(outPixels[index]>
.tg2=(outPixels[index]>
.tb2=outPixels[index]&
•
.if(tr2==tr&
&
tg==tg2&
tb==tb2)(
.outPixels[index]=(255<
16)|
(255<
.}else(
if(tr2<
5&
tg2<
tb2<
5){
・outPixels[index]=(ta2<
24)|(tr2<
16)I(tg2«
8)|tb2;
.}else{
16
)I(255«
8)|255;
.}
•}
•}
.setRGB(destlmage,0,0,width,height,outPixels);
./**
.*@paramsrc
•*@paramdest
•*@paramcolorinverse-mustbesettedhere!
!
.*/
.privatevoidembossImage(BufferedImagesrc,Bufferedlmagedest,booleancolorinverse)
intwidth=src.getWidth();
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
«
8)|
163.
164.
165.
166.}
intheight=src.getHeight();
intdw=dest.getWidth();
intdh=dest.getHeight();
int[]sinPixels=newint[width*height];
int[]dinPixels=newint[dw*dh];
src>
getRGB(饥0,width,height,sinPixels,0,width);
dest.getRGB(饥饥dw>
dh,dinPixels,0,dw);
for(inty=0;
y<
height;
y++)(
for(intx=0;
x<
width;
x++)(index=y*width+x;
intsrgb=sinPixels[index];
intrl=(srgb>
intgl=(srgb>
intbl=srgb&
if(rl>
200||gl>
=200||bl>
=200){
continue;
index2=y*dw+x;
if(colorinverse)(
rl=255-rl;
gl=255-gl;
bl=255・bl;
dinPixels[index2]=(255<
24)|(rl<
16)|(glbl;
dest.setRGB(0,0,dw,dh,dinPixels,0,dw);
程序测试代码如下:
1.packagecom•gloomyfish•zoom.study;
3.importjava•awt•BorderLayout;
4.importjava•awt•Dimension;
5.importjava•awt.Graphics;
6.importjava•awt.Graphics2D;
|7.importjava•awt•image.Bufferedlmage;
8.import
9.import
10.
10.import
12.import
13.import
14.import
15.
java.io.File;
java•io•lOException;
javax.imageio.ImagelO;
javaxeswing.^Component;
javax>
swing.JFileChooser;
javax•swing•JFrame;
classBitBltFilterTestextends^Component(
**
29•
30.
31.
33-
Bufferedlmagerawlmg;
Bufferedlmagemodlmg;
DimensionmySize;
publicBitBltFilterTest(Filef)(
try{
rawlmg=ImageIO.read(f);
modlmg=ImageIO.read(newFile(f,D:
\\resource\\geanmm.png
”));
IImodlmg=ImageIO>
read(newFile(HD:
\\resource\\gloomyfish.png"
));
}catch(lOExceptione){
e•printStackTrace();
mySize=newDimension(2*modlmg•getWidth()+20,modlmg.getHeight()+100);
34•filterlmage();
35.finalDFrameimageFrame=new3Frame(nEmbossText-gloomyfi
sh“);
36•imageFrame•getContentPane()•setLayout(newBorderLayout());
37.imageFrame•getContentPane().add(this,BorderLayout•CENTER);
38.imageFrame.setDefaultCloseOperation(JFname•EXIT_ON_CLOSE);
39.imageFrame•pack();
40.imageFrame•setVisible(true);
41.}
42.
42.privatevoidfilterlmage(){
43.BitBltFilterfilter=new);
45.
filter•emboss(rawlmg^modlmg);
46.
47.
publicvoidpaint(Graphicsg)(
49.
Graphics2Dg2=(Graphics2D)g;
50.
g2•drawlmage(rawlmg,饥饥rawlmg•getWidth(),rawlmg•getHeig
51.
ht(),null);
g2.drawlmage(modlmg^rawlmg•getWidth()+1饥0,modlmg•getWidt
52.
h(),modlmg.getHeight(),null);
g2.drawstring("
textimage11,rawlmg•getWidth()/2,rawlmg•getH
eight()+10);
g2.drawStping("
shappedtextinimage”,modlmg.getWidth()+1
54.
modlmg•getHeight()+10);
publicDimensiongetPreferredSize()(
returnmySize;
publicDimensiongetMinimumSize()(
publicDimensiongetMaximumSize(){
publicstaticvoidmain(String[]args)(
DFileChooserchooser=newJFileChooser();
chooser.showOpenDialog(null);
Filef=chooser•getSelectedFile();
newBitBltFilterTest(f);
73.)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图像 处理 数字 水印 doc
![提示](https://static.bdocx.com/images/bang_tan.gif)