CImg库中部分函数的作用和用法
部分內容來自于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。
?
GitHub:https://github.com/fengbingchun/CImg_Test
總結
以上是生活随笔為你收集整理的CImg库中部分函数的作用和用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CImg库的一个简单例子
- 下一篇: CImg库介绍