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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:48:44+00:00 2026-06-14T10:48:44+00:00

I’m a student in Electrical Engineering. As an assigment I need to implement the

  • 0

I’m a student in Electrical Engineering.

As an assigment I need to implement the back projection algorithm used in medical imaging to form in image.
To calculate the final image a lot information is calculated and kept in a vector.
At a certain desired resolution (256*256 pixels) of the final image, the program crashes as I run out of RAM, so I decided to write this information to 90 text files.

I use ofstream to write these file.

The time needed to calculate this information and then storing it in the vector is:

  • output resolution 64×64 : 13,4s
  • output resolution 128×128 : 140s

Writing this information in .txt files:

  • 64×64 156s (1,25 MB/file)
  • 128×128 1400s (5MB/file)

Code writing to files:

ofstream file;
    for(k = 0; k < 90; k++)
        {    
        oss.str(""); //string stream
        oss << "rec\\reconstruction_matrix_step"<< k << ".txt" ; // per step other file
        filename = path;
        filename.append(oss.str());
        file.open(filename.c_str());
        double weight;
          for( l = 0; l < resolution; l ++)
          {

           bestand << "Begin " << l << endl;
           l_border = - WIDTH*(resolution*1.0/2.0 - l);
           r_border = - WIDTH*(resolution*1.0/2.0 - l) + WIDTH;

           for(i = 0; i < resolution; i++)
           {
              for(j = 0; j < resolution; j++)
              {  
                     file << getSurface(pixels[i][j], l_border, r_border) << "\t";
              }
                file << "\n";
           }
           file << "End" << l << "\n\n\n";
          }
            file.close();
        }

When I use a vector, getSurface(pixels[i][j], l_border, r_border) is put in a vector instead of being written to a file.

Is there any way I can speed up this proces?

  • 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-06-14T10:48:45+00:00Added an answer on June 14, 2026 at 10:48 am

    Try changing the format from text to binary; this might reduce file size (and file writing time) greatly.

    file.open(filename.c_str(), ios_base::binary);
    ...
    // The following writes a vector into a file in binary format
    vector<double> v;
    const char* pointer = reinterpret_cast<const char*>(&v[0]);
    size_t bytes = v.size() * sizeof(v[0]);
    file.write(pointer, bytes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.