Some tips and tricks for PYTHON-OPENCV

Source: Internet
Author: User

Some tips and tricks for PYTHON-OPENCV

When using PYTHON-OPENCV to process an image, you can take a picture as a matrix and perform vector operations like MATLAB to speed up the operation of your code.

Here are a few common things to remember

1. The Mask image (mask) that takes the pixel value in the image to satisfy a specific condition

Mask = Imge < (b, G, R)

The mask size returned by this operation is equal to the image and the number of channels is equal, independently judging whether the pixel value of each channel satisfies the condition.

Mask = (Image < (b, G, R)). All (Axis = 2)

The mask size returned by this operation is equal to the image size, only one channel, combined to determine three conditions return True/false

2. Find the horizontal ordinate in the mask image that is not a zero area

X, y = np.where (mask)

3. Find the mean of three channels for the specified coordinates x, y

Mu_b, mu_g, Mu_r = Np.mean (Skin_picture[x, y,:],axis = 0)

4. Using masks to act on images

# image as one channel  for  in range (3):    = Mask * image[:,;, I] #图像为三通道

Some tips for PYTHON-OPENCV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.