Michael Michael - 2 months ago 41
C# Question

How to copy segment from the image?

I have Emgu image :

Image<Bgr,byte> image = new Image<Bgr,byte>("image.jpg");

Here is how the file(image.jpg) looks like:

enter image description here

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.


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;

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