1 / 57

页面描述语言

页面描述语言. 主讲:樊丽萍 上海理工大学 出版印刷学院. 第六章 图像输出与模板设计. §6.1 图像的特点与特征参数. 取样图像(图像):取样值的矩形数组. 1. 图像的特点:. ◎二维数组的集合 —— 元素为像素点灰度值 ◎以行的方式保存数据 ◎每个像素值 (取样值) 有1、3或4个分量构成 ◎分量的位数为1、2、4、8或12. 2. 图像(特征)参数. 图像分辨率、尺寸大小、位分辨率和图像模式. ◎源图像格式: 行数(宽)、列数(高)、彩色分量数和每个分量的位数. ◎提供图像取样数据的 数据源 : 由高*宽*分量数*位数/分量 构成.

edda
Download Presentation

页面描述语言

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 页面描述语言 主讲:樊丽萍 上海理工大学 出版印刷学院

  2. 第六章 图像输出与模板设计 §6.1 图像的特点与特征参数 取样图像(图像):取样值的矩形数组 1. 图像的特点: ◎二维数组的集合——元素为像素点灰度值 ◎以行的方式保存数据 ◎每个像素值(取样值)有1、3或4个分量构成 ◎分量的位数为1、2、4、8或12

  3. 2. 图像(特征)参数 图像分辨率、尺寸大小、位分辨率和图像模式 ◎源图像格式: 行数(宽)、列数(高)、彩色分量数和每个分量的位数 ◎提供图像取样数据的数据源: 由高*宽*分量数*位数/分量 构成 ◎用户空间坐标和源图像空间坐标的对应关系: 定义了用户空间接受图像的区域 ◎由源图像分量值到当前彩色空间的映射关系

  4. 3.取样数据的描述 colorimage、image 、imagemask 参数 image imagemask colorimage dict image components=1 components=3、4 ①图像源格式的参数: width、height、components、bit/ component

  5. ② 图像数据源——分量值(0~2n -1) 过程:每次必须返回完整的扫描行数据 文件:执行某种解码或还原过程 字符串:一般为十六进制,可重复使用 图像数据 所有分量从同一数据源中轮流读出 单数据源 多数据源 0 ~1.0 每个分量从各自的数据源中获取,数据类型要相同

  6. 4.图像变换矩阵 (w,h) (0,0) 图像变换矩阵 源图像坐标系:从左到右,从下到上: [0 0 w h] 图像变换矩阵 :定义了图像空间与用户空间之间的 映射关系 图像操作符扫描次序: 从左到右,从下到上 或从左到右,从上到下 源图像

  7. h 当前页面 (1,1) image matrix CTM (0,0) w (0,0) unit square in user space 源图像 以这种方式映射到单位正方形的图像可使用PS操作符 例:将图像映射到其左下角(100,200),宽80,高150,且逆时针旋转45度的矩形中: 100 200 translate 45 rotate 80 150 scale

  8. (0,0) w h 图像变换矩阵 h (0,0) w 从左到右,从下到上的扫描次序 [width 0 0 height 0 0 ] 从左到右,从上到下的扫描次序 [width 0 0 -height 0 height ]

  9. §6.2 图像与色彩空间 每分量位数 1.单色图像——灰度图像 ①width height bit/comp matrix datasrc image ②dict image 图像变换矩阵 图像数据源:串、文件、过程 图像词典 注意:通常图像数据以行的格式出现在PS程序中

  10. 例6.1 写出下列程序结果 %!ps %new601.ps /inch {72 mul} def /fade < FFFF FFFF FFFF FFFF EEEE EEEE EEEE EEEE DDDD DDDD DDDD DDDD CCCC CCCC CCCC CCCC BBBB BBBB BBBB BBBB AAAA AAAA AAAA AAAA 9999 9999 9999 9999 8888 8888 8888 8888

  11. 7777 7777 7777 7777 6666 6666 6666 6666 5555 5555 5555 5555 4444 4444 4444 4444 3333 3333 3333 3333 2222 2222 2222 2222 1111 1111 1111 1111 0000 0000 0000 0000 >def 1.5 inch 2.5 inch translate 6 inch 6 inch scale 16 16 4[16 0 0 -16 0 16] {fade} image showpage 8位

  12. 4位 8位

  13. 图像词典构成

  14. Decode数组:线性映射 Decode 图像数据流0~2n -1 当前彩色空间的彩色分量值 映射转换的最大值和最小值 其中:o为输出值,i为输入值

  15. 典型的Decode数组

  16. 例6.2 写出下列程序执行的结果 %!ps %new602.ps /inch {72 mul} def /temp 42 string def 1.5 inch 2 inch translate 210 150 scale << /ImageType 1 /Width 21 /Height 15 /BitsPerComponent 8 /ImageMatrix [21 0 0 -15 0 15] /DataSource {currentfile temp readhexstring pop} /Decode [0 1] >> Substring boolean

  17. image ede3e1d7c9b29a8c8e84797169666766676464676b dbd9ceac8f8384747b8b7e5d514744464d575b6063 d3be8c859bc2d99f6f837a5b524140373743535c61 b8846bacce9f71563633363837363d3c3f41465661 8386b173493f3f3a5b684c33322f353c3b42444d5f 96af87455f9d856c98ad522a3335334c4b37414959 99705e93e4e07f6a99803c2d333c325b875b3e4c56 9593b2e3ffff8c4661432e313d4a356daf9050455e eaeac5caf9ffce4a404742475752458cb19a633d5d fff5ccc3d3f9ffa548454c51504e80afa97d495383 ffede1b2bad4e8eeb46c5254628ead9b785f5d85ab fffee5cac9adabc8d3c5b2aaa39d877b8392978a98 fffee1d6b9b1a093949294988f8478717f78606aad fffff6e6cbae9d867c78706f6a65615f5a4d5ea4d9 fffffef4e5cbb19e8d87807a6f6159545672add7e0 showpage

  18. 2.彩色图像 仅适用于行格式 从单个数据源中轮流读取各个分量 数据组织 从不同数据源中获取各个分量 width height bit/comp matrix datasrc multi ncomp colorimage dict image 图像数据彩色分量个数 决定图像数据源个数 false:只有一个数据源 datasrc; true:有ncomp个数据源 datasrc0┅ datasrc n-1;

  19. 例6.3 写出下列程序的运行结果 %!ps %new603.ps /inch {72 mul}def /fade 48 string def 2 inch 2.5 inch translate 45 rotate 6.4 inch 2.4 inch scale 166 4 [16 0 0 -6 0 6] {currentfile fade readhexstring pop} false 3 colorimage

  20. 0f0 1f1 2f2 3f3 4f4 5f5 6f6 7f7 8f8 9f9 afa bfb cfc dfd efe fff ff0 ff1 ff2 ff3 ff4 ff5 ff6 ff7 ff8 ff9 ffa ffb ffc ffd ffe fff f00 f11 f22 f33 f44 f55 f66 f77 f88 f99 faa fbb fcc fdd fee fff f0f f1f f2f f3f f4f f5f f6f f7f f8f f9f faf fbf fcf fdf fef fff 00f 11f 22f 33f 44f 55f 66f 77f 88f 99f aaf bbf ccf ddf eef fff 0ff 1ff 2ff 3ff 4ff 5ff 6ff 7ff 8ff 9ff aff bff cff dff eff fff showpage 忽略所有非十六进制字符

  21. 例6.4 写出下列程序的运行结果 %!ps %new604.ps /inch {72 mul}def /DeviceCMYK setcolorspace /temp 56 string def 2 inch 2.5 inch translate 5.6 inch 2.4 inch scale

  22. << /ImageType 1 /Width 7 /Height 6 /BitsPerComponent 8 /ImageMatrix [7 0 0 -6 0 6] /DataSource {currentfile temp readhexstring pop} /Decode [0 1 0 1 0 1 0 1] >> image

  23. 640000005a00000050000000460000003c0000003200000028000000 00640000005a00000050000000460000003c00000032000000280000 0000640000005a00000050000000460000003c000000320000002800 646400005a5a000050500000464600003c3c00003232000028280000 00646400005a5a000050500000464600003c3c000032320000282800 640064005a005a0050005000460046003c003c003200320028002800 showpage

  24. 例6.5 写出下列程序的运行结果 %!ps /tempr 200 string def /tempg 200 string def /tempb 200 string def /rfile (e:\\Fan_Liping\\PStest\\duckyR.ps) (r) file def /gfile (e:\\Fan_Liping\\PStest\\duckyG.ps) (r) file def /bfile (e:\\Fan_Liping\\PStest\\duckyB.ps) (r) file def

  25. gsave 216 216 translate 200 218 scale 200 218 8 [200 0 0 -218 0 218 ] {rfile tempr readhexstring pop} {gfile tempg readhexstring pop} {bfile tempb readhexstring pop} true 3 colorimage grestore /Times-Roman 72 selectfont 216 144 moveto 1 0 0 setrgbcolor (Ducky) show showpage

  26. 3.蒙版的使用(Mask) 蒙版:使图像中的某些区域为透明,某些区域 为不透明区域(用当前色着色)的技术 模板蒙版:利用二值图像作为着色依据 蒙版 直接二值图像蒙版:使一幅图像成为另一 幅图像输出透明度控制的依据 颜色键蒙版:在图像词典中指定一种颜 色或某一区域作为透明区域 用欲显示 图像填充 用当前色填充 透明区域处露出下面图形

  27. ①模板蒙版 蒙版 不透明 透明 图像像素值:1 0 width height polarity matrix datasrc imagemask dict imagemask true:像素值为1的部分当前色着色 false:像素值为0的部分当前色着色

  28. 例6.6写出下列程序的结果 %!ps %new605.ps 72 144 translate 500 500 scale 0.8 setgray 0 0 1 1 rectfill 1 0 0 setrgbcolor 24 23 true [24 0 0 -23 0 23]

  29. < 003b00 002700 002480 0e4940 114920 14b220 3cb650 75fe88 17ff8c 175f14 1c07e2 3803c4 703182 f8edfc b2bbc2 bb6f84 31bfc2 18ea3c 0e3e00 07fc00 03f800 1e1800 1ff800 > imagemask showpage

  30. 003b00 000000000011101100000000

  31. ②直接二值图像蒙版——dict3 image 蒙版 被取样图像填充 原有图形内容 图像像素值:1 0 Type3 图像词典项(必须)

  32. ③颜色键蒙版——dict4 image(MaskColor) 蒙版 与颜色值匹配区域为透明 指定颜色值 例6.7 写出下列程序的结果 %!ps %new6074.ps /inch {72 mul}def /temp 48 string def /DeviceRGB setcolorspace 1.25 inch 2.5 inch translate 1.0 0.45 0 setcolor

  33. 0.2 inch neg dup 3.8 inch 1.6 inch rectfill 3.2 inch 1.2 inch scale << /ImageType 4 /MaskColor [0 0 0 1 0 1 ] ( [0 0 7]) /Width 16 /Height 6 /BitsPerComponent 4 /Decode [0 1 0 1 0 1 ] /ImageMatrix [16 0 0 -6 0 6] /DataSource {currentfile temp readhexstring pop} >> image

  34. 0f0 0e0 0d0 0c0 0b0 0a0 090 080 070 060 050 040 030 020 010 000 ff0 ee0 dd0 cc0 bb0 aa0 990 880 770 660 550 440 330 220 110 000 f00 e00 d00 c00 b00 a00 900 800 700 600 500 400 300 200 100 000 f0f e0e d0d c0c b0b a0a 909 808 707 606 505 404 303 202 101 000 00f 00e 00d 00c 00b 00a 009 008 007 006 005 004 003 002 001 000 0ff 0ee 0dd 0cc 0bb 0aa 099 088 077 066 055 044 033 022 011 000 showpage

  35. §6.3 使用与设计模板Form 1.模板的作用 对不同页面或同一页面的不同位置上重复使用的任意图形、图像和文字的控制 2.模板的特点 定义一次、传送一次、解释一次、存于缓存中 3.主要用途 ①完整页面的模板 ②重复对象的模板 模板词典 4.模板构造和调用: form execform

  36. ①描述模板——词典 模板词典构成

  37. ②调用模板——execform ◎执行gsave ◎把Matrix与CTM相乘 ◎根据Bbox项进行裁剪 ◎执行newpath ◎把模板词典压入操作数栈 ◎执行模板词典中的PaintProc ◎执行grestore

  38. 例6.8 写出下列程序的运行结果 %!ps /inch {72 mul}def /Font1 {/Times-Bold 18 selectfont }def /Form 8 dict def Form begin /FormType 1 def /BBox [0 0 4 inch 7 add 2.7 inch ]def /Matrix [1 0 0 1 0 0] def

  39. /TitlesForm 5 dict def TitlesForm begin /FormType 1 def /BBox [0 0 3.5 inch 2.4 inch ]def /Matrix [1 0 0 1 0 0] def /PaintProc{ Font1 0.25 inch 2.1 inch moveto (Name:) show 0.25 inch 1.8 inch moveto (Address:) show 0.25 inch 1.2 inch moveto (Phone:) show 0.25 inch 0.9 inch moveto (Birthday:) show } def end

  40. /insertNotch{ 0 0.1857 inch rlineto -0.0625 inch 0 rlineto 0 0.3125 inch rlineto 0.25 inch 0 rlineto 0 -0.3125 inch rlineto -0.0625 inch 0 rlineto 0 -0.1857 inch rlineto } def /DrawBox { 1.4357 inch 7 moveto insertNotch 2.4357 inch 7 moveto insertNotch 4 inch 7 4 inch 2.5 inch 25 arcto 4 inch 2.5 inch 0 2.5 inch 25 arcto 0 2.5 inch 0 7 25 arcto 0 7 4 inch 7 25 arcto closepath } def

  41. /PaintProc{ begin gsave 7 -7 translate DrawBox 0.6666 setgray fill grestore DrawBox 1 setgray fill DrawBox 0 setgray stroke 0 0 moveto TitlesForm execform }def end /R1 {Font1 (Name:)stringwidth pop 0.25 inch add }def /R2 {Font1 (Address:)stringwidth pop 0.25 inch add }def /R3 {Font1 (Phone:)stringwidth pop 0.25 inch add }def /R4 {Font1 (Birthday:)stringwidth pop 0.25 inch add }def

  42. %The first page 1 inch 1 inch translate 300 300 moveto Form execform 0 0 1 setrgbcolor R1 2.1 inch moveto (Mary) show R2 1.8 inch moveto (330 Neijiang Rd.) show R3 1.2 inch moveto (56780000) show R4 0.9 inch moveto (07/08/82) show showpage

  43. %The second page 1 inch 1 inch translate 300 300 moveto Form execform 1 0 0 setrgbcolor R1 2.1 inch moveto (Jack) show R2 1.8 inch moveto (100 Shuifeng Rd.) show R3 1.2 inch moveto (56780000) show R4 0.9 inch moveto (05/10/82) show showpage

  44. %The third page 1 inch 1 inch translate 300 300 moveto Form execform 0 1 0 setrgbcolor R1 2.1 inch moveto (Lily) show R2 1.8 inch moveto (110 Nanjiang Rd.) show R3 1.2 inch moveto (56780400) show R4 0.9 inch moveto (11/05/81) show showpage

  45. 第二页 第三页 第一页

More Related