Commit 8e274774 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

improve block extraction

parent bf123336
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment