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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:29:31+00:00 2026-06-13T10:29:31+00:00

I am creating a photo mosaic in Java. The inputs to it are the

  • 0

I am creating a photo mosaic in Java. The inputs to it are the Target Image and a collection of tiles. Below is my algorithm for the same:

a. Read all the tiles from the directory and process* it. [Every tile is of the same dimension.]
b. Read the target image, break it into cells [cells are of dimensions of a tile.]
c. Process* all the cells.
d. For each cell:
  d.1. Create a HashMap h [where key=euclidean metric, value=corresponding tile]
  d.2. For each tile:
    d.2.1 Calculate Euclidean metric.
    d.2.2 add it to h.
  d.3 Calculate min from h.
  d.4 Add the min to an outputList
e. Create the image from list of images in the outputList.

The *process method takes in an image and creates an object of a class we defined called ImageDetails. So for every tile and cell that is processed, there is an ImageDetails object created which stores details like its RGB value and dimensions. There are 2 separate lists of objects: one for tiles and other for cells.

The problem is that there are about on average 300 tiles and as much as 50,000 cells (can be more than that too!). So while my program runs, it has these many objects in memory, besides the calculations and other ip/op operations it performs.

When I run this program on a machine with low resources (less available memory) the output image created is distorted. But when I run it on a machine with more available resources, it is perfect. I think it is because it is not able to hold all the objects in memory at once when there are no resources available. So I see an image which has misplaced tiles. But when it has enough memory, I see perfect output image.

What can I do to ensure that regardless of the available memory, I can retain the order of the elements added in the outputList so that I can see an image without distortions.

Thanks.

EDIT:

Below are the 2 images that are the output of the same program. the only difference is that they are run on different machines. Please help me in understanding the difference in the output of the programs given the algorithm and the constraints.

enter image description here

enter image description here

  • 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-13T10:29:32+00:00Added an answer on June 13, 2026 at 10:29 am

    It probably doesn’t have anything directly to do with memory – either you have enough or you don’t.

    What collection class are you using for outputList? ArrayList and LinkedList should both guarantee the order of the elements.

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

Sidebar

Related Questions

I am creating a photo application where the user selects and image from the
I'm creating PHP, Javascript based photo-gallery from scratch The problem is, I want to
I'm creating a photo viewer which the user can use to tag images like
I am creating a photo editor app where, at some point, the photo you
Is there any way creating a photo gallery using Listview control ? Im playing
I'm creating a little photo sharing site for our home's intranet, and I have
I am having some trouble creating a seamless photo grid. I have searched the
I'm a newbie who is creating a lightweight photo showcase site written on the
I am currently working on creating a webpage photo gallery. I have a ton
I am creating an app that send photo on email,i have created gallery,now i

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.