Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x_pad, y_pad = 0, 0
- # Basically what's happening here is I'm trying to get the number of pixels
- # needed to pad the image so it can be chopped into equal 256x256 squares.
- #
- # To do this I first check if the pixel count is already cleanly divisible by
- # 256, and then if it's not, I then try to figure out how much more height I
- # need to add. I do that by first dividing the pixel count by 256 and then
- # adding 1 to it to give me a clean multiple of 256 to work with. Afterwards I
- # I multiply that by 256 to get the ideal height, and then subtract that number
- # by how many pixels I already have so that I get the number of pixels I need
- # to pad it by.
- #
- # After all that is done I divide it by 2 so it can be padded equally on both sides
- if (image.rows % 256) > 0
- x_pad = (256 * ((image.rows / 256) + 1)) - image.rows
- x_pad = x_pad / 2
- end
- if (image.columns % 256) > 0
- y_pad = (256 * ((image.columns / 256) + 1)) - image.columns
- y_pad = y_pad / 2
- end
Add Comment
Please, Sign In to add comment