Visual c++ 获取图像的像素值

Visual c++ 获取图像的像素值,visual-c++,opencv,pixel,Visual C++,Opencv,Pixel,下面是提供两幅图像的宽度、高度和BGR值的代码。但问题是,在关闭第一幅图像之前,我看不到第二幅图像。需要进行哪些修改,以便一次可以看到两幅图像并获得所有像素值 1 . #include <cv.h> #include<iostream> #include <cxcore.h> #include <highgui.h> using namespace std; int main(int argc, char** argv[]) { int

下面是提供两幅图像的宽度、高度和BGR值的代码。但问题是,在关闭第一幅图像之前,我看不到第二幅图像。需要进行哪些修改,以便一次可以看到两幅图像并获得所有像素值

1 . #include <cv.h>
#include<iostream>
#include <cxcore.h>
#include <highgui.h>

using namespace std;

int main(int argc, char** argv[])
{
    int  width,height;
     int i=0,j=0,k=3,l=3;

        IplImage *img1 = cvLoadImage("E:/images.jpg");
        cvNamedWindow("Image1:",1);
        cvShowImage("Image1:",img1);
        cout << "Width:" <<  img1->width << endl;
        cout << "Height:" <<  img1->height << endl;
        CvScalar s;
        s=cvGet2D(img1,i,j); // get the (i,j) pixel value
        printf("B=%f, G=%f, R=%f\n",s.val[0],s.val[1],s.val[2]);
        cvWaitKey();
        cvDestroyWindow("Image1:");

        IplImage *img2 = cvLoadImage("C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg");
        cvNamedWindow("Image2:",2);
        cvShowImage("Image2:",img2);
        cout << "Width:" <<  img2->width << endl;
        cout << "Height:" <<  img2->height << endl;

        s=cvGet2D(img2,k,l); // get the (k,l) pixel value
        printf("B1=%f, G1=%f, R1=%f\n",s.val[0],s.val[1],s.val[2]);
        cvWaitKey();
        cvDestroyWindow("Image2:");

        cvReleaseImage(&img1);
        cvReleaseImage(&img2);

        return 0;
}
1#包括
#包括
#包括
#包括
使用名称空间std;
int main(int argc,字符**argv[]
{
int宽度、高度;
int i=0,j=0,k=3,l=3;
IplImage*img1=cvLoadImage(“E:/images.jpg”);
cvNamedWindow(“图像1:”,1);
cvShowImage(“图像1:”,img1);

cout问题在于
cvWaitKey()
尝试:

IplImage*img1=cvLoadImage(“E:/images.jpg”);
cvNamedWindow(“图像1:”,1);
cvShowImage(“图像1:”,img1);
库特
    IplImage *img1 = cvLoadImage("E:/images.jpg");
    cvNamedWindow("Image1:",1);
    cvShowImage("Image1:",img1);
    cout << "Width:" <<  img1->width << endl;
    cout << "Height:" <<  img1->height << endl;
    CvScalar s;
    s=cvGet2D(img1,i,j); // get the (i,j) pixel value
    printf("B=%f, G=%f, R=%f\n",s.val[0],s.val[1],s.val[2]);



    IplImage *img2 = cvLoadImage("C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg");
    cvNamedWindow("Image2:",2);
    cvShowImage("Image2:",img2);
    cout << "Width:" <<  img2->width << endl;
    cout << "Height:" <<  img2->height << endl;

    s=cvGet2D(img2,k,l); // get the (k,l) pixel value
    printf("B1=%f, G1=%f, R1=%f\n",s.val[0],s.val[1],s.val[2]);


    cvWaitKey();
    cvDestroyWindow("Image1:");
    cvDestroyWindow("Image2:");
    cvReleaseImage(&img1);
    cvReleaseImage(&img2);