Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Rotating equirectangular maps (G'mic script, GIMP and Krita) + Sinusoidal projection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Tutorial Rotating equirectangular maps (G'mic script, GIMP and Krita) + Sinusoidal projection

    Here is a script to arbitrarily rotate an equirectangular map with roll, pitch and yaw rotations in G'mic.

    There are G'mic plugins for GIMP and Krita, and if you're on Ubuntu and getting your GIMP from a 2.10 ppa you should already have it.

    Otherwise, you can download G'mic from https://gmic.eu/download.shtml

    To install the script, create a text-file with the contents of this paste-bin, named either user.gmic or .gmic depending on the system.
    https://pastebin.com/NKN9VEE4

    EDIT: MollyJ has provided some fixes for bugs I think might affect people with newer versions of the Gmic plugin (I can't, after months of not touching the thing, even figure out how to update it): https://pastebin.com/6ZuwezVw

    If the old version of the script doesn't work, try this one. Should be the same way to install it as a user.gmic or .gmic file :TIDE

    user.gmic is for Windows users. You copy that file into a directory where the G'mic plugin can find it. In my test-case, /Users/%username%/AppData/Roaming seemed to work, but this... Isn't reliable, if my googling is correct.

    Linux and Mac users just put .gmic into your /~ home folder. Just straight there.

    This text file is the single file that G'mic will scan for new scripts, so if you want more scripts that aren't already in the G'mic standard library, you have to append them into the text file (and same if you already have the file installed, you just copy the contents of what I provide here into it).

    equirectangular-rotation-tutorial.png

    To run the script, open up GIMP or Krita and open a new Equirectangular map image. Technically, you can open anything and the script won't crash or anything, but to test it download something like one of the smaller downloads of this Wikimedia Blue Marble map.

    If you don't see the Map Projection subfolder in the list of G'mic scripts, try refreshing all the scripts with the Refresh button on the bottom middle of the window.

    The Equirectangular Rotation plugin lets you just rotate an equirectangular map, and is super, super useful to get rid of polar distortion and copy/paste bits and pieces of a map by rotating it so what you want is in the middle and then copying that into the middle of another map. This is basically a streamlined version of my old "getting rid of polar distortion" tutorial here, years and years back, that used the Hugin panorama stitching application.

    The Sinusoidal projection plugin is the same, except it outputs the map into a sinusoidal projection, and even slices it if you want.

    Don't expect to see many more projections, figuring out the exact black magic invocations for just these two, super simple projections was painful. And that's not even talking about scripting this all in G'mic.

    I have tried to keep my scripts as readable as possible, and invite anyone to extend and replace them.
    Attached Files Attached Files
    Last edited by Naeddyr; 03-20-2022 at 02:20 PM.

  2. #2

    Default A request to publish a g'mic script as a maintainer of g'mic-qt

    Hi, OP

    Considering that you have described the process of making this through matrice mathematics and conversion from spherical coordinates to planar coordinates and mentioned that these scripts are public domain. I would like to let you know that I will push the filters into the g'mic-qt filter as I learned they're public domain. It should be seen within gmic-community@github in a day or two so that other users can access this via g'mic-qt plugin within Krita/GIMP/Paint.NET.

    Thank you so much for this.

  3. #3
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Default

    Quote Originally Posted by Reptorian View Post
    Hi, OP

    Considering that you have described the process of making this through matrice mathematics and conversion from spherical coordinates to planar coordinates and mentioned that these scripts are public domain. I would like to let you know that I will push the filters into the g'mic-qt filter as I learned they're public domain. It should be seen within gmic-community@github in a day or two so that other users can access this via g'mic-qt plugin within Krita/GIMP/Paint.NET.

    Thank you so much for this.
    No problem! I am currently torturing myself with a script that I hope will let me generate equal-area pseudo-cylindrical projections. I've already made a simpler script that let's me generate "naive" 'triangular' projections, one of which is the Eckert I projection. I'll put a pastebin here with the triangular script:

    https://pastebin.com/NKN9VEE4

    eckert1.png

  4. #4

    Default

    In case you don't get my response over reddit, I am working on improving your work pertaining to g'mic-qt. These will be what I'll be doing:

    1. Improve performance by eliminating redundancy.
    2. Making it better by changing code to address issues.

    Then, I will leave comments after I pushed so you can understand what I did.

  5. #5
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Default

    https://pastebin.com/NKN9VEE4

    Updated the script, added a bunch of different projections.

    At one point, I finally had a workable template to work from and the basic knowledge of how to translate projections. The trick is to use inverse formulas, and in this https://epic.awi.de/id/eprint/39585/...letin_1532.pdf has been a godsend, because unlike Mathworld or Wikipedia it's actually helpful.

    Full list of projections in alphabetical order:

    Albers Equal Area Conic
    Azimuthal equidistant
    Conic equidistant
    Cylindrical equal area (containing preset settings for Lambert, Gall-Peters etc.)
    Eckert I (as a special case of "triangular projection")
    Eckert IV
    Eckert VI
    Lambert Azimuthal Equal-Area
    Lambert Conformal Conic
    Mercator
    Mollweide
    Orthographic
    Sinusoidal
    and "triangular"

  6. #6

    Default

    Is there a way to force the equirectangular map rotation script to run in reverse?

    Currently, I'll take my map, and apply a pitch of -150 and a yaw of 65 to center a continent for work.

    If I then try to use a pitch of 150 and a yaw of -65 to move it back into place it won't work. Instead I'm forced to apply the yaw of 65 first, then the pitch of 150.

    I imagine this is because the script applies Roll -> Pitch -> Yaw. Is there a way I could add a button that causes the operations to run Yaw -> Pitch -> Roll?

    Note: I'm unfamiliar with how G'mic works, and only installed it because I came across these scripts.

  7. #7
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Default

    Quote Originally Posted by willuwontu View Post
    Note: I'm unfamiliar with how G'mic works, and only installed it because I came across these scripts.
    Hi,

    don't worry about it. Even if I wrote the above scripts, I really don't understand G'mic.

    Long story short, I've upgraded my linux distro recently and just spent half an hour trying to figure out how to install the G'mic plugin again, and I took a look at the script just now, and I've got annoying news for you. Afaic remember and tell from looking at it, the order of the operations is baked in into the maths formulas I used.

    I say "annoying" because there is a workaround. You just have to apply the rotations in reverse one at a time: first a Yaw correction, apply, then a Pitch correction, apply, and finally a Roll correction, apply.

    It's been a few months since I tackled this supremely annoying scripting language and I have completely forgotten all about it. It's basically Frankensteinian monster using shell scripting stuff in the most horrifying way possible. I don't think I ever used any IF statements if I could avoid them, they were just a pain to figure out, and the maths I just artfully copied researched on the internet for ages, so I'm not going to update the script or anything. I'd have to relearn everything.

  8. #8

    Default

    Quote Originally Posted by Naeddyr View Post
    Hi,

    don't worry about it. Even if I wrote the above scripts, I really don't understand G'mic.

    Long story short, I've upgraded my linux distro recently and just spent half an hour trying to figure out how to install the G'mic plugin again, and I took a look at the script just now, and I've got annoying news for you. Afaic remember and tell from looking at it, the order of the operations is baked in into the maths formulas I used.

    I say "annoying" because there is a workaround. You just have to apply the rotations in reverse one at a time: first a Yaw correction, apply, then a Pitch correction, apply, and finally a Roll correction, apply.

    It's been a few months since I tackled this supremely annoying scripting language and I have completely forgotten all about it. It's basically Frankensteinian monster using shell scripting stuff in the most horrifying way possible. I don't think I ever used any IF statements if I could avoid them, they were just a pain to figure out, and the maths I just artfully copied researched on the internet for ages, so I'm not going to update the script or anything. I'd have to relearn everything.
    That's understandable, I just wanted to see if there was anything other than doing the operations 1 at a time that could reverse it.

    I might take a look at the scripts in the future and see if I can do something about it.

  9. #9
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Default

    Quote Originally Posted by willuwontu View Post
    That's understandable, I just wanted to see if there was anything other than doing the operations 1 at a time that could reverse it.

    I might take a look at the scripts in the future and see if I can do something about it.
    The last thing I tried to figure out last night before going to bed was whether it would be possible to "reverse" or "revert" or any other googleable word the rotations with a simple math formula, but all the stuff I found was newbie game devs being explained to use quaternions or matrices... If the problem can be reduced to something like that, a simple formula for the rotations that give you their "reverse" rotations that unmake the first rotation, it wouldn't be too hard to apply that as a simple toggle called [Revert] or whatever...

  10. #10
    Guild Adept Naeddyr's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    300

    Default

    I actually did it!

    Turns out that if you create the kind of combined rotation matrix I used in the script, if you do the multiplications of the individual rotation matrices in "the wrong" order you get different results that do the rotations in different orders. So if you multiply Yaw and Pitch and then Roll you get the "reversion" matrix to the one I used in the script, and I was able to pretty easily plug it in... Except it took me half an hour figuring out the exact if-statement syntax in the script, before noticing I should have been trying to figure out the other kind of if-statement syntax, half an hour more figuring out the other kind of if-syntax again and after debugging by putting minus signs in front of every single alpha, beta and gamma in the else-branch formulas, bob's your uncle!

    I left a gui toggle in the Rotate Equirectangular Map script only, because the other scripts don't really need this functionality that much. With the same values (do not turn the angles negative) just click on Revert and you should get the same rotations as before the first transformation. Of course the distortions on the edges are really bad, but that's life.

    https://pastebin.com/NKN9VEE4
    Last edited by Naeddyr; 01-13-2021 at 03:16 AM.

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •