Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Walk pixel by pixel over the area inside the triangle.
This is how they do it for the entire image, it remains to replace two nested loops over all points in it with the points of the triangle.
About a triangle, look for an algorithm for pixel-by-pixel filling of a triangle or write it yourself, to pixelate a line, take Bresenham's algorithm
You can only cut a rectangular ROI.
However, it is possible to cut out a rectangular ROI that will describe the desired triangle. And using the cv2.fillConvexPoly() function, fill the extra parts of the image with black (0, 0, 0). When determining the average color, it is important to take into account the number of pixels in the triangle, and not everything in the rectangular ROI.
rPman's solution is basically the same.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question