简体   繁体   中英

How can I split image as pizza in cv2?

比萨

I wanna split an image in cv2 as shown in the picture and get the dominant color for each of the parts of the picture. Is there any function so I can give it parameters (a, b, c, d) for the count of lines to up, right, bottom and down of the picture and it returns color in rgb space?

Usually this is done not by the count of lines (up, down, left, right), but by the angle of one pizza slice. The whole pizza is 360 degrees, so you may choose a number like 10-20-30 degrees, to make slices even. Then take the x, y coordinates of the image pixel and after subtracting the center pixel coordinates calculate the slice number as atan((y - y_center)/(x - x_center)) .

To avoid calculation complications, you may want to split the calculation into the two similar, but separate cases when x > x_center and x < x_center to avoid ZeroDivide and make life easier.

Regarding the dominant colors, there are a bunch of articles on this site, just use the search, I don't want to copy-paste someone else's work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM