Skip to content

Instantly share code, notes, and snippets.

@p-geon
Last active August 9, 2018 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p-geon/ec9d3650359701f9fdcc3ddd61fb4584 to your computer and use it in GitHub Desktop.
Save p-geon/ec9d3650359701f9fdcc3ddd61fb4584 to your computer and use it in GitHub Desktop.
from tqdm import tqdm
import numpy as np
from skimage.io import imread, imsave
win_h = win_w = 640
orig = imread(fname="image_A.png")
ours = imread(fname="image_B.png")
def main():
for i in tqdm(range(1)):
h_bias, w_bias = np.random.randint(0, orig.shape[0]-win_h), np.random.randint(0, orig.shape[1]-win_w)
crop_orig = orig[h_bias:h_bias+win_h, w_bias:w_bias+win_w]
crop_ours = ours[h_bias:h_bias+win_h, w_bias:w_bias+win_w]
conc = np.concatenate([crop_orig, crop_ours], axis=1)
imsave(fname=f"./cropped/crop_{i:03d}_ours.png", arr=crop_ours)
imsave(fname=f"./cropped/crop_{i:03d}_orig.png", arr=crop_orig)
imsave(fname=f"./cropped/crop_{i:03d}_compare.png", arr=conc)
if __name__ == "__main__":
main(); print("\007")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment