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 6705475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:24:29+00:00 2026-05-26T07:24:29+00:00

I am trying to do my first project in MATLAB and so far I

  • 0

I am trying to do my first project in MATLAB and so far I try to load a sequence of images from a directory and store them in one object.

The images are small and they are quite few < 100, so memory is not a problem.

I would optimally store them in a 3 dimensional array, but I don’t know how to do it.

Can you tell me how to load images and store all them in a stack?

So far here is the code I have written:

function image = load_image_array(dir, start, finish)
    for i = start:finish

        filename = [ dir '/' sprintf('%08d', i) '.jpg' ];
        image = importdata( filename, 'jpg' );

        figure( i );
        imagesc( image );

    end
end

Do you think it is a good idea to preallocate the array in advance? Also, is 3 dimensional array a good idea? I would like to have RGB images, do I need to have 3 stacks or a 4 dimensional array for this?

  • 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-26T07:24:30+00:00Added an answer on May 26, 2026 at 7:24 am

    Assuming they’re all the same size, storing them in a stack is as simple as:

    ...
    imageStack(i,:,:) = image;
    ...
    imagesc( squeeze(imageStack(i,:,:)) );
    

    If they’re not the same size, just use a cell array:

    ...
    imageStack{i} = image;
    ...
    imagesc( imageStack{i} );
    

    My syntax may be off for the cell array, test it out and play with it. I’ll try to remember to doublecheck it when I get to work later.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to access my first ruby project. After navigating to the proper directory
I'm trying out my first Spring project and must be doing something really stupid
I am writing a quick application myself - first project, however I am trying
I am trying to write my first WCF project. I have created a project
I'm trying to setup my first Rails3 project and, early on, I'm running into
I am trying to run the example code from the MATLAB Doc, but when
I am trying to convert my model-first project to code-first, as I can see
Trying to get my first MVC + EF code first project to run. The
I'm trying to build my first project with the andengine. things work fine so
I'm new to Autofac and trying to get things working for my first project

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.