现在的位置: 首页 > 综合 > 正文

CImg库中部分函数的作用和用法

2012年09月11日 ⁄ 综合 ⁄ 共 1998字 ⁄ 字号 评论关闭

部分内容来自于CImg参考手册或CImg的Doxygen手册

 

1、宏cimg_usage(usage):可以被用来描述程序的目的和使用情况。它通常被插入到 int main(int argc, char **argv)的定义之后。

     参数:usage:描述程序目的和使用情况的字符串。

     前置条件:使用cimg_usage()的函数必须正确的定义了变量argc和argv。

2、CImg<unsigned char> image("lean.jpg"), visu(500, 400, 1, 3, 0);

    创建两个使用unsigned char型像素的图像的实例。第一个图像image通过从磁盘读取一幅图像文件来初始化。此处,lena.jpg必须同当前程序在同一目录下。第二个图像visu被初始化为一幅黑色的彩色图,它的大小事dx=500(长), dy=400(宽), dz=1(深)(这里,它是一幅2D图像,而不是一幅3D图像),并且dv=3(每个像素拥有3个‘向量’通道R,G,B)。在构造函数中的最后一个参数定义了像素值的缺省值(这里是0,也就是说visu将被初始化为黑色)。

3、宏cimg_option(name, default, usage):用来从命令行检索一个选项值。

    参数:name:将从命令行检索的选项的名字;

            default:在运行程序时如果选项name没有被指定,此宏返回的缺省值;

            usage:选项的一个简要说明。如果usage==0,当带有参数-h或-help运行程序时,此选项不会出现在选项列表中(隐藏此选项)。

    返回值:cimg_option()返回一个同缺省值default有相同类型的对象。返回的值同在命令行中所指定的那个相同。如果某选项没有被指定,返回的值等于缺省值default。

    前置条件:使用cimg_option的函数必须正确的定义了变量argc和argv。

4、CImg get_norm_pointwise():return the scalar image of vector norms,when dealing with vector-valued images (i.e images with dimv()>1), this function computes the L1,L2 or Linf norm of each vector-valued pixel。

5、CImg normalize():linear normalization of the pixel values between a and b

6、CImg resize():resize an image。

7、CImgDisplay main_disp(image, "Click a point");

     为图像image创建一个显示窗口,缺省情况下,CImgDisplay处理(来自鼠标、键盘,...)的事件。在windows上,有一个创建全屏显示的方法。

8、const unsigned char red[] = { 255, 0, 0 }, green[] = { 0, 255, 0 };

    定义了两种不同的颜色,每种颜色都是const unsigned char数组。

9、CImg dimx():return the number of columns of the instance image (size along the X-axis, i.e image width)。

10、cimg::dialog():display a dialog box, where a user can click standard buttons。

11、cimg::basename():compute the basename of a filename。

12、CImg get_resize():return a resized image。

13、CImgDisplay is_closed:closed state of the window。

14、CImgDisplay key:key value if pressed。

15、CImgDisplay wait(CImgDisplay& disp1, CImgDisplay& disp2):wait for any event occuring either on the display disp1 or disp2。

16、CImg get_gradientXY():return a list of images, corresponding to the XY-gradients of an image。

17、CImg blur():blur the image with a Canny-Deriche filter。

18、CImg fill(val):fill an image by a value val。

19、CImg display(CImgDisplay& disp):display an image into a CImgDisplay window。

抱歉!评论已关闭.