I'm new to C++ and I'm trying to create an 500x500 pixel RGB image. The image should be filled by linear interpolation of four colours, each defined for one of the corners so I should have something like:
Vec3b ul( 255, 0, 0 ); //upper left corner
Vec3b ur( 0, 255, 0 ); //upper right corner
Vec3b bl( 0, 0, 255 ); //bottom left corner
Vec3b br( 255, 0, 255 ); //bottom right corner
The end result should look like this:
The program then displays the image in a window etc etc... I can do that stuff but I just need to figure out how to put the colours in the image. My code so far is this:
#include <QtCore/QCoreApplication>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <iostream>
#include <string>
#include <sys/stat.h>
using namespace cv;
int main()
{
Mat image;
image.create( 500, 500, CV_8UC3);
//upper left corner
Vec3b ul( 255, 0, 0 );
//upper right corner
Vec3b ur( 0, 255, 0 );
//bottom left corner
Vec3b bl( 0, 0, 255 );
//bottom right corner
Vec3b br( 255, 0, 255 );
namedWindow("Colored Pixels");
imshow("Colored Pixels", image);
// shows image for 5 seconds
waitKey(5000);
return 0;
}
and the output is
I'd be glad to hear your suggestions!