Group closer white pixels together and draw a rectangle around them in OpenCV

前端 未结 2 565
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 00:57

I want to group these white pixels that are closer to each other and draw a rectangle around them in OpenCV using C++.

Original Image:

2条回答
  •  面向向阳花
    2021-01-20 01:40

    You can count integral in each row and column. Then search for places where this integral is continuously growing. Here you can also add some moving average to exclude noise etc. Then this places means that here is more white than in other parts. Now you can use rectangle function from openCV to draw rectangle around this area (http://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html#rectangle).

提交回复
热议问题