Gray = cv2.cvtColor(mask, cv2.COLOR_BGR2GRAY)Ĭnts = cv2.findContours(gray, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)Ĭnts = cnts if len(cnts) = 2 else cntsĬv2. The result will be similar to cv2.dilate() with the added benefit of color selection We can specify the color and adjust the size using the thickness parameter. When we want to only enhance a particular part of an image but leave other sections untouched, we can use cv2.drawContours(). Kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3,3))ĭilate = cv2.dilate(mask, kernel, iterations=1) Iterations=1 (left), iterations=2 (middle), iterations=3 (right) More iterations will generate a thicker line Lower value of alpha like 2 or 3 is good. Each pixel of the input image will change according to this formula. We create a structuring element and dilate. def changebrightness (img, alpha, beta): return cv2.addWeighted (img, alpha, np.zeros (img.shape, img.dtype),0, beta) Here alpha & beta are input parameters. Define the proper function to change the brightness and contrast in order to use the cv2.addWeighted () Display all the modified image using cv2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |