1.2 Multimedia 多媒体
Bit-map images 位图
位图(Bit-map image)是由 像素(Pixel)组成的图像。像素也叫作像元或图形元素(Picture Element), 是组成位图的最小元素。
常见的位图文件格式有:bmp, jpg, jpeg, png 等。
Note
Bit-map Image: system that uses pixels to make up an image.
Pixel: smallest picture element that makes up an image.
Function of Pixels: Each pixel stores colour information, contributing to the overall image.
像素以网格形式排列;像素的水平数量和垂直数量定义了图像的 分辨率(Resolution)。
当存储位图时,若要存储彩色图像,一个像素至少需要占用一个 byte 来存储,这样一共可以存储 256 种(
在位图中,每种颜色通道所占用的 bit 的数量称为图像的 位深(Bit Depth);一个像素所占用的 bit 的数量叫作 色深(Colour Depth)。
Tip
因为色深和位深是相互对应的,习惯上,我们也用位深的方式表示色深,如:真彩色图像的色深是 24-bit. 下文中也会有类似用法。
Note
Colour depth: the number of bits used to represent a pixel.
Bit depth: the number of bits used to represent each of the red, green and blue colours.
色深和文件大小的关系: Higher colour depth increases the file size, as more data is needed to store the colour information for each pixel.
Tip
色深是位深的一种具体表现,但位深不止可以表示色深,详见下表。
Bit Depth | Colour Depth (bit) | Colour Depth | 示例 |
---|---|---|---|
1-bit | 1-bit | 2 种颜色(黑 / 白) | 纯黑白图像(如 Fax) |
2-bit | 8-bit | 256 种颜色 | 灰度图像或 gif |
16-bit | 65,536 种颜色(High Colour) | 早期计算机图像 | |
8-bit | 24-bit | 16,777,216 种颜色(True Colour) | 普通照片、屏幕显示(如 jpg) |
8-bit | 32-bit | 16,777,216 种颜色 + 透明度 | png、hdr 图像 |
图像分辨率(Image Resolution)是组成一个图像的像素数量,通常以 宽 × 高(像素数) 表示。
如:某张照片的图像分辨率是
屏幕分辨率(Screen Resolution)是组成屏幕显示的水平和垂直像素数量。
如:全高清(Full HD)的显示器,分辨率为
Note
Image Resolution: number of pixels that make up an image
Screen Resolution: number of horizontal and vertical pixels that make up a screen display
分辨率越高,图像的细节越丰富,但文件大小也会随之增加。
同时,我们使用 像素密度(Pixel Density)来衡量图像的清晰度。像素密度越大,显示效果越细腻。一般以 像素每英寸(Pixels Per Inch, PPI)作为像素密度的单位,普通计算机屏幕的像素密度约为 72 PPI,而现代智能手机的像素密度通常超过 300 PPI,甚至达到 400-500 PPI 以提供更清晰的视觉体验。
以 PPI 为单位的像素密度计算公式:
位图的文件大小计算
位图的文件大小可以用如下公式计算:
例 16:
For a bit-map image with resolution
解答:
影响位图大小的因素
分辨率:像素数(即
)越多,文件越大;色深:色深越大,文件越大;
压缩(Compression)可以减小文件大小,具体原理在 1.3 中提到。
修改图像的影响
对分辨率的修改:
放大(Up-scaling)
Up-scaling increases resolution artificially but can lead to blurriness(模糊)or pixelation(像素化,即看上去像马赛克).
缩小(Down-scaling) Down-scaling reduces file size but can remove important details, making images appear less sharp.
对色深的修改:
增加色深(Enhancing Colour Depth) Enhancing colour depth adds more colour variations, improving visual quality, but at the expense of larger files.
减少色深(Reducing Bit Depth) Reducing bit depth cause noticeable quality loss, such as colour banding, where distinct bands of colour appear instead of smooth gradients.
文件头(File Headers)
File headers store essential data about the image, crucial for rendering it correctly.
It includes:
File type, so the software can decode / decompress the file correctly.
Image resolution
Bit / colour depth
Compression method
功能:Enables image viewing and editing software to interpret and manipulate the image data accurately.
图像质量的考虑因素
平衡分辨率和位深:对于专业摄影、高质量打印和详细的图形工作需要更高的分辨率和颜色深度;而对于 Web 和 移动应用程序,通常,较低的分辨率和颜色深度就足够了,可以优化更快的加载时间和更少的存储空间。
由使用场景决定:专业人士可能更喜欢 BMP 或 TIFF 等未压缩格式进行编辑,而业余用户可能会选择 JPEG 等压缩格式进行日常使用;同时,在 Web 应用中,大型、高质量的图像会占用更多的存储空间和带宽,从而影响网站加载时间和存储容量。
练习 5
Calculate the fize size of a bit-map image with resolution
, colour depth 32-bit.Explain the differences between bit depth and colour depth.
Discuss the impact of changing the resolution of a bitmapped image and its implications for file size and image quality.
Vector graphics 矢量图
矢量图(Vector Graphic Images) 是通过 数学公式 来描述的图像,而不是像素网格。它使用 点、直线、曲线、形状 等对象来构建图像,每个对象由数学方程定义,因此可以 无损缩放,即不论放大还是缩小,图像的清晰度都不会改变。矢量图中用于存储和管理图形元素的结构叫作 绘图列表(Drawing List),它包含一系列 绘图对象(Drawing Objects),如 线条、矩形、圆形、多边形和文本,每个对象由数学公式定义,且都有特定的属性,例如颜色、粗细、描边样式和填充图案;可以更改这些属性,而不会影响图像的整体质量。绘图列表的主要作用是 按顺序记录和渲染图形对象,使得矢量图形能够被无损缩放和编辑。
常见的矢量图文件格式有:svg, cgm, odg, ai 等
Note
Vector Graphic: a graphic consisting of drawing objects defined in a drawing list
Drawing List:
(1 分题简化版) All the drawing objects in an image
(完整版):
a list that stores the commands required to draw each object
attribute that defines property
records the relative position of drawing objects
Property: defines one aspect of the apperance of the drawing object
矢量图不是存储像素,而是存储 绘图指令 和 数学方程。例如,在 arduino 中,绘制一个圆的方式可能是:
circle(center_x=50, center_y=50, radius=20, fill_color="red", stroke_color="black")
位图和矢量图的比较
Vector Graphic Images | Bit-map Images |
---|---|
made up of geometric shapes which require definition / attributes | made up of pixels of different colours |
to edit the design, it is necessary to change each of the geometric shapes | possible to edit each of the pixels to change the design of the image |
made up by simple geometric shapes so do not require large file size | pixels give very accurate designs so the file size is very large |
the number of geometric shapes is limited so they are not usually very realistic | images are built up pixel by pixel so the final image is usually very realistic |
file formats are usually .svg, .cgm, .odg | file formats are usually .jpeg, .png, .bmp |
位图的优点和局限性
优点
Detail and Complexity: Bit-map images are excellent for rendering complex, detailed images like photographs. They can capture subtle gradations in colour and texture with great precision.
Colour Depth: Bit-map images can display a vast range of colours, making them ideal for high-fidelity colour reproduction.
局限性
The primary limitation of bit-map graphics is their lack of scalability. Enlarging a bit-map image leads to pixelation and loss of clarity. Additionally, high-resolution bit-map images can have large file sizes.
矢量图的优点和局限性
优点
Scalability: Vector graphic images can be enlarged or reduced without any loss of image quality, making them perfect for applications where resizing is frequent.
File Size: For graphics with less complexity, vector graphic images are much smaller than their bitmap counterparts.
Editability: Vector graphic images are composed of individual, editable elements. This makes modifying specific parts of an image much simpler and more efficient.
局限性
Vector graphic images are not well-suited for displaying highly detailed images like photographs due to their geometric nature.
选择位图和矢量图
如果图像需要缩放(关键词:resize, up-scale / down-scale, magnify),则选择矢量图;
如果图像需要按比例绘制(关键词:to scale),则选择矢量图;
如果图像需要拟真(关键词:look real, realistic),则选择位图;
如果有文件格式要求,则需要根据要求选择位图或矢量图;
如果有文件大小要求,则根据有无格式要求,选择矢量图或控制位图的分辨率;
常见情况:
对于 Web 和数字媒体,以及 Logo,因为需要缩放,用矢量图;
对于需要后期修改(如 Ps 修改)的图像,用位图,因为可以只修改个别像素。
数字摄影、复杂的图形设计、详细的图稿和肖像照片用位图,因为它们需要高保真视觉表示
例 17:
In the following situation, which type of image should be used, bit-map image or vector graphic image? Why?
(a) Design a logo for a company
(b) Composing a design diagram for a car engine
(c) Take an ID photo for students
解答:
(a) Vector graphic image should be used because the logo needs to be resized for different application.
(b) Vector graphic image should be used because the design diagram needs to be drawn to scale.
(c) Bit-map image should be used because the ID photo needs to be realistic.
练习 6
Why do vector images does not loss of image quality when applies up-scaling, while bitmap images are pixelated?
Explain how vector graphics store image information.
Explain the advantages of using vector graphics over bitmap graphics in the context of web design.
Sound Files 声音文件
声音文件(Sound Files) 指的是数字化存储和处理音频数据的文件。
在录音时,声音一开始是由 模拟信号(Analogue Signal)表示的。模拟信号是用交流电信号直接模拟的声波,其频率和声音频率一致,电压和响度成正比。但计算机中存储的声音大多是由 数字信号(Digital Signal)表示的,通常以 离散的数值(即二进制数据)表示。将模拟信号转换为数字信号的过程叫作 数模转换(ADC, Analog-to-Digital Conversion)。该过程包括两个关键步骤:
采样(Sampling):在一定时间间隔内测量声波的振幅。
量化(Quantization):将采样的模拟信号转换为最接近的数值。
Note
Analogue data: data obtained by measurement of a physical property which can have any value from a continuous range of values
Digital data: data that has been stored as a binary value which can have one of a discrete range of values
Sampling: taking measurements at regular intervals and storing the value
为什么要进行数模转换?
Sound travels in continuous wave form but computer can only understand digital data.
Band-limiting filter: Remove high frequency data.
声音文件的大小
声音文件的大小由采样率(Sampling Rate)、采样分辨率(Sampling Resolution,又叫量化比特深度,也就是声音的 Bit Depth)来决定。
采样率是采集样本的频率,单位为 赫兹(Hz)或 千赫兹(kHz);采样分辨率的单位和 Bit Depth 一致,为 bit.
采样分辨率是每个采样点存储振幅信息使用的 bit 数。
Note
Sampling resolution: the number of bits used to store each sample
Sampling rate: the number of samples taken per second
进行 Sampling 的过程:
The amplitude of the sound wave is sampled at various set time interval
The amplitude are encoded as a binary number sequence
The sequence provides a digital representation of the sound wave
增加采样分辨率的好处和坏处:
Pros | Cons |
---|---|
larger dynamic range | produces larger file size |
better sound quality | takes longer to transmit/download sound files |
less sound distortion | requires greater processing power |
采样率和采样分辨率与声音文件的大小 成正比。
可以用以下公式计算未压缩音频的大小:
例 18:
Calculate the file size of a 3 minutes sound file with 44.1kHz, 16-bit, in terms of MB.
解答:
常见应用场景
高保真音乐需要较高的采样率和采样分辨率来捕获完整的声音频谱,这会导致文件大小更大。
电信语音需要较低的采样率和采样分辨率,因为人类语音的频率范围比音乐的频率范围窄。
Videos 视频
使用 数字相机(DV, Digital Camera)可以录制视频,DV 存储以 25 MB 每秒的速度存储视频,也被叫做 motion JPEG.
Note
Frame rate: the number of frames recorded per second
练习 7
Calculate the uncompressed audio file size for 48 kHz, 24 bit stereo (2-channels), with a duration of 2 minutes.
Explain the impact of sampling rate and sampling resolution on sound quality.
Discuss the trade-offs involved in choosing between high-fidelity music and voice for telecommunication in terms of sampling rate and bit depth. What considerations must be taken into account?
最后编辑:admin 更新时间:2025-03-17 12:13