500 likes | 649 Views
图像处理编程基础. Media. 图形&图像. 计算机图形学. 形. 像. 图像处理、计算机视觉. 有什么用?. 图像编辑( photoshop ) 数字娱乐 生物医学 相机辅助拍摄 电子警察、安全检测 城市建模、导游 信息检索(基于内容的图像检索) 自动导航 …………. A picture is worth 1000 words … A video is worth 1000 sentences …. Rich information from visual data Examples of images around us
E N D
图形&图像 计算机图形学 形 像 图像处理、计算机视觉
有什么用? • 图像编辑(photoshop) • 数字娱乐 • 生物医学 • 相机辅助拍摄 • 电子警察、安全检测 • 城市建模、导游 • 信息检索(基于内容的图像检索) • 自动导航 • …………
A picture is worth 1000 words…A video is worth 1000 sentences… • Rich information from visual data • Examples of images around us • Natural photographic images • Artistic and engineering drawings • Scientific images (satellite, medical, etc.) • Motion picture –video • Movies, TV programs, news • Family video • Surveillance and highway camera
Why do we process images? • Enhancement and restoration • remove artifacts and scratches from an old photo/movie • improve contrast and correct blurred images • Transmission and storage • images from oversea via Internet, or from a remote planet • Information analysis and automated recognition • providing “human vision” to machines • Security and rights protection • encryption and watermarking
Why Digital? • “Exactness” • Perfect reproduction without degradation • Perfect duplication of processing result • Convenient & powerful computer-aided processing • Can perform rather sophisticated processing through hardware or software • Even kindergartners can do it! • Easy storage and transmission • 1 CD can store hundreds of family photos! • Paperless transmission of high quality photos through network within seconds
Human Vision System • Image is to be seen. • Perceptual Based Image Processing • Focus on perceptually significant information • Discard perceptually insignificant information • Issues: • Biological • Psychophysical
Color • Color is the perceptual result of light having wavelength 400 nm to 700 nm that is incident upon the retina. • “Power distribution exists in the physical world, but color exists only in the eye and the brain.” • Does “red” mean the same to different people?
Grassman's First Law of Additive Color Mixture • Any color can be matched by a linear combination of three other colors (primaries, eg RGB), provided that none of those three can be matched by a combination of the other two. • C= Rc(R ) + Gc(G) + Bc(B)
Color Spaces • RGB • CMY • CIE XYZ • s
Different Image Types • Binary images (0 or 1) • Gray images (0~255) • Color images • indexed color images • full color images (24 bits per pixel, 8-red, 8-green, 8-blue) )
Gray Images • 8 bits per pixel
Full Color Images • 24 bits per pixel, and the three channels R G B are three gray images respectively
图像文件格式(1) • 矢量图(.ai, .eps, .ps, .pdf, .swf等) • draw circle • center 0.5, 0.5 • radius 0.4 • fill-color yellow • stroke-color black • stroke-width 0.05 • draw circle • center 0.35, 0.4 • radius 0.05 • fill-color black • …………
图像文件格式(2) • 位图( .bmp, .jpg, .png, .gif等) a 光栅化 (rasterize)
图像(位图)的基本属性 • 分辨率(宽×高,像素、DPI) • 像素数(Megapixels) • 颜色空间(RGB, CMYK, YUV……) • 通道数(1,2,3,4,灰度&彩色) • 位深度(8bits, 12bits,……LDR&HDR) • 存贮坐标系: 左手坐标系 右手坐标系(如.bmp)
图像表示 classCImage { intwidth, height; //分辨率 CPixel* data; //图像数据 }; class CPixel { UINT r, g, b; // red, green, blue values }; a
函数接口设计 BOOL Read(CFile* pFile); BOOL Write(CFile* pFile); int GetWidth(); int GetHeight(); RGBQUAD GetPixelAt(int x, int y); void SetPixelAt(int x, int y, BYTE r, BYTE g, BYTE b);
例子 F1 F2
变换函数 平移: 缩放: 旋转: x方向 切变 (shear): y方向
齐次坐标与变换矩阵 • 使用变换矩阵的好处: • 使各种变换具有统一的形式; • 便于将多次变换合并; • 便于用数学工具进行分析; 齐次坐标: 2维仿射变换:
Simple Transformations • Affine transformation • Perspective transformation
= 平移(-cx, -cy) + 旋转 angle + 平移 (cx, cy) 示例:绕任意中心的旋转 void CalcRotateMatrix(Matrix23 &matrix, float angle, float cx, float cy);
正向变换&逆向变换 正向: 源 目标 逆向: 目标 源
逆向变换:why? 正向变换会造成目标图像中的部分像素没有被正确赋值!
最邻近插值 双线性插值 双三次插值 逆向变换:重采样
正向变换:网格 • 先将图像剖分成均匀网格,用正向变换将网格点变换到目标位置,再插值出中间像素的坐标
用网格下采样 • Point features • Partition
用户交互:点对 • Point features
Warping Problem • Scattered point interpolation • Given the values on some points, compute the value on arbitrary other point
散乱点插值问题 • Inverted distance method • Shepard, 1965 • Spline surface fitting • Thin-plate spline • Finite element method • Radial basis function • …
接口设计 CWarping { private: vector<Cline> m_pntSpecs; public: CPoint Warping(CPoint point); int Prepare(); };
Inverted Distance Method • 用距离加权得到值
Project 1: Image Warping • 用CDib类实现 • 实现至少2种warping方法,包括Inverted weighted distance和Radial basis function方法(读参考文献) • 写详细测试报告 • 算法原理 • 实现框架(类的层次设计) • 算法实现过程及复杂度分析 • 测试例子及问题等 • Deadline: Wed. 9:30a.m., April 27, 2011