Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 849677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:08:31+00:00 2026-05-15T07:08:31+00:00

Greetings all, I read 3d grid data (from multiple TIF images) into a structure

  • 0

Greetings all,

I read 3d grid data (from multiple TIF images) into a structure as follows :

typedef struct VolumeData{
 int nx;
 int ny;
 int nz;
 unsigned char *data; // size is nx*ny*nz
}

Now I want to get the plane slices from this 1-D grid data:

eg:

unsigned char* getXYPlaneStack(VolumeData *vol,int z); 

 I could implement above function because the *data array stores image stack.

But i am having difficult time implement along the other axes:

unsigned char* getYZPlaneStack(VolumeData *vol,int x);

and

unsigned char* getXZPlaneStack(VolumeData *vol,int y);

any easy algorithm for this?
thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:08:32+00:00Added an answer on May 15, 2026 at 7:08 am

    2nd and 3rd functions both resample your data set (they are basically expressing your image in a new referential).

    So they must reorganize the data:

    1. Create a new array of size ny*nz for YZ and nx*nz for XZ
    2. Fill the array with data laying in the given plane
    3. Return the pointer to the newly allocated array

    (In this scenario, the caller is responsible of deallocating the newly allocated memory.)

    Your algorithm for the YZ plane is:

    // I assume this sorting order:
    //       Z ^          Slices are
    //        /           stacked along
    //       /            the Z axis
    //      +-------> X
    //      |
    //      |
    //    Y v
    
    // Assumes your data is stored in row major order:
    //          +-------> X        +---------> X
    // slice 0: | 0 1 2 | slice 1: | 6  7  8 | etc.
    //          | 3 4 5 |          | 9 10 11 |
    //        Y v                Y v
    // Assumes x is the column index, y the row index, z the slice index.
    // For example, you want element #9:
    // - col 0   -> x = 0
    // - row 1   -> y = 1
    // - slice 1 -> z = 1
    // I suggest you rename nx, ny, nz into nbCols, nbRows, nbSlices to make
    // things explicit
    index computeIndex(VolumeData *vol, int x, int y, int z)
    {
        int nx = vol->nx, // nb cols
            ny = vol->ny, // nb rows
            nz = vol->nz; // nb slices
        int index = nx*ny*z // size of one slice, multiplied by slice index
                  + nx*y    // size of one row (nb cols), multiplied by row index
                  + x;      // offset in row (column index)
        return index;
    }
    
    unsigned char* getYZPlaneStack(VolumeData *vol,int x)
    {
        int nx = vol->nx, // nb rows
            ny = vol->ny, // nb columns
            nz = vol->nz; // nb slices
        unsigned char *newData = new unsigned char[ny*nz];
        // Depth is now along the X axis
        //   +-----> Z
        //   |
        //   |
        // Y v
        for(int y = 0; y < ny; ++y)      // For each row
            for(int z = 0; z < nz; ++z ) // For each column
            {
                int i = computeIndex(vol, x, y, z);
                newData[nz*y+z] = vol->data[i];
            }
        return newData;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings all, I'm looking for a more efficient way to grab multiple users without
and greetings to all members. I'm working on a small embedded data acquisition hardware
Greetings, I'm going to get exif info from some images using android. I know
Greetings all, I am taking a Structure and Application of Microcomputers course this semester
Greetings All I am trying to get the values in the 4th column from
Greeting, What is the best practice to read all attributes from a child elements
Greetings all, I have a question. On my MOSS 2007 dev box, I created
Greetings all, I have a question. I am trying to build a parametrized query
Greetings all, I need help combining some htaccess rewrites, these crazy regular expressions screw
Greetings all, I'm trying to implement middleware (driver) for an embedded device with generic

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.