Semantic image segmentation - using the OpenCV extract all kinds of other areas

Problem Description:

    After using the Deeplab V3 + divided pictures obtained, the next step hope for the classes and the proportion of the pixel area, so that other aspects of the analysis, the extraction process is as follows:

Use OpenCV extraction area:

    Main process: 1 to the image from BGR HSV, color-coded to facilitate;

                      2. Use cv2.inRange function, extracts a specified color, such as: red;

                      3. Find a profile, and calculate the area profile.

    The whole process made animation, is Jiang Zi:

Difficulties: How to find HSV values ​​of the image of it?

    Method 1: Use the OpenCV cv2.cvtColor conversion, HSV values ​​obtained can then set the lower limit. however,

Some colors RGB eye can not see, the second method should be adopted at this time.

red = np.uint8([[[0, 0, 128]]])
hsv_red = cv2.cvtColor(red, cv2.COLOR_BGR2HSV)
print(hsv_red)  # [[[  0 255 128]]]

    Method 2: Using PS HSV values ​​obtained. Click on figure 1 (icon like straw), select HSB color, the figure at 2 shows the results.

Since OpenCV, H is [0, 180], S [0, 255], V [0, 255],

H is in PS [0, 360], S [0, 1], V [0, 1],

Therefore, conversion: H data in PS / 2, S x 255, V x 255 HSV values ​​obtained in OpenCV.

 

 

Guess you like

Origin blog.csdn.net/weixin_41713230/article/details/83013524