Skip to content

Commit

Permalink
docs/doc_code old code updated to match usage.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
CSRavasio committed Nov 30, 2021
1 parent 445c544 commit 5c5bbb2
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions docs/doc_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# shape = (300, 400)
# flow_1 = of.Flow.from_transforms([['rotation', 200, 150, -30]], shape)
# flow_2 = of.Flow.from_transforms([['scaling', 100, 50, 0.7]], shape)
# result = of.combine_flows(flow_1, flow_2, mode=3)
# result = flow_1.combine_with(flow_2, mode=3)
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_mask_flow1.png', flow_1.visualise('bgr'))
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_mask_flow2.png', flow_2.visualise('bgr'))
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_mask_result.png', result.visualise('bgr'))
Expand All @@ -60,7 +60,7 @@
# show_masked_image(warped_img, valid_area))
# flow_1 = of.Flow.from_transforms([['rotation', 200, 150, -30]], img.shape[:2])
# flow_2 = of.Flow.from_transforms([['scaling', 100, 50, 0.7]], img.shape[:2])
# result = of.combine_flows(flow_1, flow_2, mode=3)
# result = flow_1.combine_with(flow_2, mode=3)
# warped_img, valid_area = result.apply(img, return_valid_area=True)
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_apply_thames_warped2.png',
# show_masked_image(warped_img, valid_area))
Expand Down Expand Up @@ -267,9 +267,9 @@
# flow_2 = of.Flow.from_transforms([['scaling', 100, 50, 1.2]], shape)
# flow_3 = of.Flow.from_transforms([['rotation', 200, 150, -30], ['scaling', 100, 50, 1.2]], shape)
#
# flow_1_result = of.combine_flows(flow_2, flow_3, mode=1)
# flow_2_result = of.combine_flows(flow_1, flow_3, mode=2)
# flow_3_result = of.combine_flows(flow_1, flow_2, mode=3)
# flow_1_result = flow_2.combine_with(flow_3, mode=1)
# flow_2_result = flow_1.combine_with(flow_3, mode=2)
# flow_3_result = flow_1.combine_with(flow_2, mode=3)
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_combining_1.png', flow_1.visualise('bgr', True, True))
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_combining_2.png', flow_2.visualise('bgr', True, True))
# cv2.imwrite('C:/Users/RVIM_Claudio/Downloads/usage_combining_3.png', flow_3.visualise('bgr', True, True))
Expand Down Expand Up @@ -307,25 +307,24 @@


# # # # Flow field for README
#
# # Make a flow field and display it
# shape = (300, 400)
# flow = of.Flow.from_transforms([['rotation', 200, 150, -30]], shape)
# transform = [['rotation', 200, 150, -30]]
# flow = of.Flow.from_transforms(transform, shape)
# # flow.show()
#
# flow_2 = of.Flow.from_transforms([['translation', 40, 0]], shape)
# result = of.combine_flows(flow, flow_2, mode=3)
# result = flow.combine_with(flow_2, mode=3)
# result.show(show_mask=True, show_mask_borders=True)
# result.show_arrows(show_mask=True, show_mask_borders=True)

# img = cv2.imread('C:\\Users\\RVIM_Claudio\\Downloads\\thames_600.jpg')
# mask = np.mgrid[-img.shape[0]//2:img.shape[0]//2, -img.shape[1]//2:img.shape[1]//2]
# radius = img.shape[0] // 2 - 10
# mask = np.linalg.norm(mask, axis=0)
# mask = mask > radius
# img[mask] = 0
# cv2.imshow('test', img)
# cv2.waitKey()
#
# # Alternative option without using the custom flow class
# flow = of.from_transforms(transform, shape, 't')
# of.show_flow(flow)
# flow_2 = of.from_transforms([['translation', 40, 0]], shape, 't')
# result = of.combine_flows(flow, flow_2, mode=3, ref='t')
# of.show_flow(result) # Note: no way to show the valid flow area (see documentation)
# of.show_flow_arrows(result, 't') # Note: again no way to show the valid flow area

# # # # Images for the repo "social preview"
# img = cv2.imread('_static/thames_300x400.jpg')[60:-40]
Expand Down

0 comments on commit 5c5bbb2

Please sign in to comment.