Skip to content

Commit 30faab4

Browse files
committed
Add IMAGE_SCALE parameter
1 parent 481d3b3 commit 30faab4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# number of divisions per channel
1616
# (COLOR_DEPTH = 32 -> 32 * 32 * 32 = 32768 colors)
1717
COLOR_DEPTH = 32
18+
# Scale of the image to be tiled (1 = default resolution)
19+
IMAGE_SCALE = 1
1820
# tiles scales (1 = default resolution)
1921
RESIZING_SCALES = [0.5, 0.4, 0.3, 0.2, 0.1]
2022
# number of pixels shifted to create each box (tuple with (x,y))

tiler.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
# number of colors per image
1515
COLOR_DEPTH = conf.COLOR_DEPTH
16+
# image scale
17+
IMAGE_SCALE = conf.IMAGE_SCALE
1618
# tiles scales
1719
RESIZING_SCALES = conf.RESIZING_SCALES
1820
# number of pixels shifted to create each box (x,y)
@@ -29,11 +31,14 @@ def color_quantization(img, n_colors):
2931

3032

3133
# returns an image given its path
32-
def read_image(path):
34+
def read_image(path, mainImage=False):
3335
img = cv2.imread(path, cv2.IMREAD_UNCHANGED)
3436
if img.shape[2] == 3:
3537
img = cv2.cvtColor(img, cv2.COLOR_BGR2BGRA)
3638
img = color_quantization(img.astype('float'), COLOR_DEPTH)
39+
# scale the image according to IMAGE_SCALE, if this is the main image
40+
if mainImage:
41+
img = cv2.resize(img, (0, 0), fx=IMAGE_SCALE, fy=IMAGE_SCALE)
3742
return img.astype('uint8')
3843

3944

@@ -148,7 +153,7 @@ def most_similar_tile(box_mode_freq, tiles):
148153
# builds the boxes and finds the best tile for each one
149154
def get_processed_image_boxes(image_path, tiles):
150155
print('Getting and processing boxes')
151-
img = read_image(image_path)
156+
img = read_image(image_path, mainImage=True)
152157
pool = Pool(POOL_SIZE)
153158
all_boxes = []
154159

0 commit comments

Comments
 (0)