New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How tf.image.extract_image_patches works ? #29857
Comments
Please the this excellent explanation on StackOverflow: https://stackoverflow.com/questions/40731433/understanding-tf-extract-image-patches-for-extracting-patches-from-an-image I don't think there's a bug here, so I will close this issue. |
(That said, I am adding a proper docstring to |
@martinwicke : Hi, I've read it. |
1250/256 = 4.8.., because you use 'same' padding, you round up. The sizes (512) is not relevant to determine how many patches there are, only how big they are (they can overlap). |
Fixes #29857. PiperOrigin-RevId: 254797260
Example:
Output_extracted will have shape: But we calculate:
4.8 rounds up = 5 So the correct answer should be ( 1, 4, 4, 262144 ) |
Please make sure that this is a bug. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template
System information
Describe the current behavior
I want to extract a large gray scale image from (1250 x 1250) to patches (512 x 512). So I tried to run tf.image.extract_image_patches on both versions: TF 1.13.1 and TF 2 Beta follow this tutorial.
My parameters:
tf.image.extract_patches will output a matrix image patches 5x5.
The zero paddings = 143 on each edge.
I don't understand why we have 5 pictures in a row?
How tf.image.extract_patches works ?
Describe the expected behavior
It should be 4x4 matrix image patches with zero paddings = 15 on each edge.
Denote n is the number of stride steps.
The number image patchs = n + 1
Input_size = 1250
Output_size= 512
Stride = 256
Padding:
We have an equation:
2*Padding + Input_size = n*Stride + Output
(1)We don't know how many zero padding we need. So:
Input_size <= n*Stride + Output
1250 <= n*256 + 512
Then 2.88 <= n .
We choose the nearest interger n = 3.
(1) => zero padding = 15
Will will have 4x4 matrix image patches with zero paddings = 15 on each edge.
Please correct me if my calculation is wrong.
The text was updated successfully, but these errors were encountered: