Combining a matrix image.
I want to combine two images into one.
Combine only image, without background(.png)
Paste the image at coordinates.
If somewhere pixels overlap with the previous picture, inform( return -1;)
EXAMPLE:
Image1(a matrix):
101
001
Image1(a matrix):
01
00
Image1+Image2(through the point A(0;0))
111
001
Image1+Image2(through the point C(1;0))
Error.Because, images intersect in point X(3;0)
Help please.
I will be very grateful.
I am Newbie in openCv, it's all that I have done:
Mat stamps(char* name)
{
Mat src = imread(name, 1);
Mat dst;//(src.rows,src.cols,CV_8UC4);
Mat tmp, alpha;
cvtColor(src, tmp, CV_BGR2GRAY);
threshold(tmp, alpha, 100, 255, THRESH_BINARY);
Mat rgb[3];
split(src, rgb);
Mat rgba[4] = { rgb[0], rgb[1], rgb[2], alpha };
merge(rgba, 4, dst);
return dst;
}
int main()
{
Mat image1=imread("...name");//in
Mat image2 =stamps("....name");//from
int x=0,y=0;
image2.copyTo(dst.rowRange(y, y + image2.size().height).colRange(x, x + image2.size().width));
}
//result with background
imread("...name") loads a 3-channel image, your stamps() output has 4, now look at the error , again.
You are right, thank.But how to check whether they intersect?
To check whether 2 images intersect you need to compare coordinates, take a look here.