Skip to content

Instantly share code, notes, and snippets.

@JonasDaWi
Forked from Don-Moahskarton/UE4_landscape_tiler.py
Created September 18, 2020 09:13
Show Gist options
  • Save JonasDaWi/89091abfb66965d58ca8668d9e0d09ef to your computer and use it in GitHub Desktop.
Save JonasDaWi/89091abfb66965d58ca8668d9e0d09ef to your computer and use it in GitHub Desktop.
import cv2
import sys
import numpy as np
#config
outputSize = 1017
image = cv2.imread('in.png', cv2.IMREAD_UNCHANGED)
dimensions = image.shape
# height, width, number of channels in image
height = image.shape[0]
width = image.shape[1]
print('heightmap Height : ',height)
print('heightmap Width : ',width)
#imS = cv2.resize(image, (512, 512))
#cv2.imshow("original (512 resize)", imS)
x_name = 0
x = 0
while x+outputSize < width:
y = 0
y_name = 0
while y+outputSize < height:
out_file_name = "IMG_X" + str(x_name) + "_Y" + str(y_name) + ".png"
print("Currently rendering " + out_file_name)
crop_image = image[y:y+outputSize, x:x+outputSize]
cv2.imwrite(out_file_name, crop_image.astype(np.uint16))
y+=outputSize-1
y_name+=1
x+=outputSize-1
x_name+=1
cv2.waitKey(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment