Skip to content
Snippets Groups Projects
Commit ccd8bca8 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

improve block extraction

parent 743a775c
Branches
Tags
No related merge requests found
...@@ -329,18 +329,12 @@ def blocks_tensorflow(images, block_size): ...@@ -329,18 +329,12 @@ def blocks_tensorflow(images, block_size):
block_size = [1] + list(block_size) + [1] block_size = [1] + list(block_size) + [1]
output_size = list(block_size) output_size = list(block_size)
output_size[0] = -1 output_size[0] = -1
# extract image patches for each color space: output_size[-1] = images.shape[-1]
output = [] blocks = tf.extract_image_patches(
for i in range(3): images, block_size, block_size, [1, 1, 1, 1], "VALID"
blocks = tf.extract_image_patches( )
images[:, :, :, i : i + 1], block_size, block_size, [1, 1, 1, 1], "VALID" n_blocks = int(numpy.prod(blocks.shape[1:3]))
) output = tf.reshape(blocks, output_size)
if i == 0:
n_blocks = int(numpy.prod(blocks.shape[1:3]))
blocks = tf.reshape(blocks, output_size)
output.append(blocks)
# concatenate the colors back
output = tf.concat(output, axis=3)
return output, n_blocks return output, n_blocks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment