Skip to content
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

Switch to using C-order for image data #9

Merged
merged 19 commits into from
Jan 9, 2019
Merged

Conversation

addisonElliott
Copy link
Owner

Within the realm of computing, there are two ways of storing multidimensional data:

  • C-order: Gets its name from C where you typically create a multidimensional array like so int data[z][y][x]. This is backwards from traditional mathematics where you represent coordinates as (x, y, z). This format of storing data can also be thought of as slowest-varying to fastest-varying. The z-axis typically varies slowest, followed by y-axis, finished with the x axis.
  • Fortran-order: Direct opposite of C-order and is how MATLAB and Fortran handle multidimensional array indexing. This method follows the traditional mathematical representation of (x, y, z). It makes sense that MATLAB and Fortran use this method because they are languages geared towards data scientists. This format of indexing data can be thought of as fastest-varying to slowest-varying.

Previously, this package wasn't using C-order or Fortran-order but did a weird collage of both. This could be confusing to new users and I wanted to stick to a particular syntax.

Why switch to C-order?

Python, Numpy, and many other libraries use this format for storing and indexing data. Numpy provides support for changing the order but it can be a pain to include for each call. Thus, I decided to stick with this syntax that Python follows.

What changes were made?

Here is the general thought process I used. When returning coordinates, Fortran-order was used because that is intuitive for the average user who is familiar with coordinates from math courses. For example, it is much more intuitive to use (x, y) for a point rather than (y, x). The polar domain equivalent is (r, theta).

Images and image shapes or sizes are in C-order to stick with the overwhelming agreement in the Python community.

Color channels are considered to be faster varying than the x axis.

For example, let's assume you have 50 RGB images with a width of 1024px and height of 2048px. The Numpy array of the images should be (50, 2048, 50, 3). This is what polarTransform expects when given an image. Let's say that you convert it to the polar domain, the resulting image will have a shape of (50, angular size, radial size, 3).

Color images with channels > 1 must be specified by using the parameter hasColor. This is handled by moving the color channel to the front of the dimensions, performing transformation, and then moving back after transformation is complete.

@addisonElliott addisonElliott merged commit a6f2a6c into master Jan 9, 2019
@addisonElliott addisonElliott deleted the switch-to-C-order branch January 9, 2019 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant