官术网_书友最值得收藏!

  • OpenCV 4 with Python Blueprints
  • Dr. Menua Gevorgyan Arsen Mamikonyan Michael Beyeler
  • 230字
  • 2021-06-24 16:50:03

Applying morphological closing for smoothening

A common problem with segmentation is that a hard threshold typically results in small imperfections (that is, holes, as in the preceding image) in the segmented region. These holes can be alleviated by using morphological opening and closing. When it is opened, it removes small objects from the foreground (assuming that the objects are bright on a dark foreground), whereas closing removes small holes (dark regions).

This means that we can get rid of the small black regions in our mask by applying morphological closing (dilation followed by erosion) with a small 3 x 3-pixel kernel, as follows:

kernel = np.ones((3, 3), np.uint8)
frame = cv2.morphologyEx(frame, cv2.MORPH_CLOSE, kernel)

The result looks a lot smoother, as follows:

Notice, however, that the mask still contains regions that do not belong to the hand or arm, such as what appears to be one of the knees on the left and some furniture on the right. These objects just happen to be on the same depth layer of my arm and hand. If possible, we could now combine the depth information with another descriptor, maybe a texture- or skeleton-based hand classifier that would weed out all non-skin regions.

An easier approach is to realize that most of the time, hands are not connected to knees or furniture. Let's learn how to find connected components in a segmentation mask.

主站蜘蛛池模板: 西乌珠穆沁旗| 任丘市| 吉隆县| 揭西县| 陕西省| 长寿区| 自治县| 资源县| 太仓市| 哈巴河县| 邛崃市| 临湘市| 稷山县| 汉寿县| 富川| 祁门县| 临泽县| 牙克石市| 凉城县| 米易县| 云林县| 涡阳县| 延津县| 汾阳市| 萍乡市| 广水市| 那曲县| 海口市| 甘孜县| 江华| 于田县| 陈巴尔虎旗| 建平县| 白朗县| 济源市| 柳州市| 长子县| 格尔木市| 蒙山县| 襄汾县| 阜新|