How to copy segment from the image?

c#, emgucv, image-processing, opencv

Solution

In the opencv c++ api you can just use the matrix copy function with a mask composed of your triangular components.

Mat image = imread("image.jpg",CV_LOAD_IMAGE_COLOR);
vector<Point> triangleRoi;
Mat mask;

//draw your trianlge on the mask
cv::fillConvexPoly(mask, triangleRoi, 255);

Mat copiedSegment;
image.copyTo(copiedSegment,mask);

You should beable to write some similar code in emgu based on this.

Problem

I have Emgu image : ``` Image<Bgr,byte> image = new Image<Bgr,byte>("image.jpg"); ``` Here is how the file(image.jpg) looks like: All pixels that inside red-yellow triangle I want to copy to the new image called: ``` Image<Bgr,byte> copiedSegment; ``` Any idea how to implement it if I have coordinates all coordinates of the triangle contour. Thank you in advance.

Original source