Created
March 19, 2015 15:21
-
-
Save tomasaschan/e88f952f135797430324 to your computer and use it in GitHub Desktop.
Toroidal image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define the following stuff somewhere | |
type ToroidalImage | |
img | |
end | |
import Base.getindex | |
getindex(timg::ToroidalImage, x, y) = timg.img[mod1(x, size(timg.img,1)), mod1(x, size(timg.img,2))] | |
# Then use like so | |
img = rand(100,50) | |
torimg = ToroidalImage(img) | |
mypixel = torimg[105, -10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for that (and sorry for leaving earlier) but I can't see how does that solve the issue of translating the whole image. For example, if I want to translate the whole image in the x direction by 5 pixels say, I still have to do something a kind of T_img = img[1:x + 5, :], which is not possible. And you can't do things like new_img = img[a:b, c:d] anymore to pick only part of the image.
Edit: well, it does work for [[1:x] + 5, :] if I change mod1 by mod though, good! Thanks!