So open the file with the name how_devide_image_without_save.py and add the next code: # At first Horizontal devide left1 image #rotate image LEFT1 to 90 CLOCKWISE img = cv2.rotate(left1, cv2.ROTATE_90_CLOCKWISE) # start vertical devide image height = img.shape width = img.shape # Cut the image in half width_cutoff = width // 2 l1 = img l2 = img # finish vertical devide image #rotate image to 90 COUNTERCLOCKWISE l1 = cv2.rotate(l1, cv2.ROTATE_90_COUNTERCLOCKWISE) #save cv2.imwrite("one_horisont_1.jpg", l1) #rotate image to 90 COUNTERCLOCKWISE l2 = cv2.rotate(l2, cv2.ROTATE_90_COUNTERCLOCKWISE) #save cv2.imwrite("one_horisont_2.jpg", l2) # At first Horizontal devide right1 image#rotate image RIGHT1 to 90 CLOCKWISE img = cv2.rotate(right1, cv2.ROTATE_90_CLOCKWISE) # start vertical devide image height = img.shape width = img.shape # Cut the image in half width_cutoff = width // 2 r1 = img r2 = img # finish vertical devide image #rotate image to 90 COUNTERCLOCKWISE r1 = cv2.rotate(r1, cv2.ROTATE_90_COUNTERCLOCKWISE) #save cv2.imwrite("second_vhorisont_1.jpg", r1) #rotate image to 90 COUNTERCLOCKWISE r2 = cv2.rotate(r2, cv2.ROTATE_90_COUNTERCLOCKWISE) #save cv2.imwrite("second_horisont_2.jpg", r2) 3 You should see something like that. ![]() ![]() Will rotating these 2 images to 90 degrees and after that will be dividing images into vertical parts and after that rotate to 90 degrees (COUNTERCLOCKWISE) and save 2 images for the left side. Divide the image into vertical parts (Photo,GIF by Author) 2 But for divide image into 4 parts you need add code which will:
0 Comments
Leave a Reply. |