會使用到

cvResize

 

範例圖片一樣使用筆記(1)的那張

開始撰寫程式碼!


#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main()
{
    char fileName[] = "D:\\聖誕節.jpg";
    IplImage *image, *newImage;
    
    image = cvLoadImage(fileName);
    if (!image)
    {
        cout << "找不到檔案!!!" << endl;
    }
    else
    {
        newImage = cvCreateImage(CvSize(image->width / 2, image->height / 2), IPL_DEPTH_8U, 3);//將圖片縮小為原先的一半
        cvResize(image, newImage, CV_INTER_AREA);

        cout << "Image:" << endl;
        cout << "Width:" << image->width;
        cout << ", Height:" << image->height << endl << endl;
        cout << "New Image:" << endl;
        cout << "Width:" << newImage->width;
        cout << ", Height:" << newImage->height << endl;

        cvShowImage("image", newImage);
        cvWaitKey(0);
    }

    system("pause");
    return 0;
}


執行結果如下

arrow
arrow
    全站熱搜

    Yang 發表在 痞客邦 留言(0) 人氣()