Need help with graphics with 280 million pixels

Just starting out? Need help? Post your questions and find answers here.
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

Well, 800 by 560 is 1 pixel reprents 625 people. What I don't know is how to do the mechanics of it. I can display that many pixels and fill them all in with a color or random colors, whatever.

What I'm wondering is: Is there a way to let the resolutions resolve itself as part of the mechanism already implace when you display a large image at lower resolution.

How would you guys work on this part of the mechanics (those of you who do graphics). I'm just looking to be pointed in the right direction (I don't expect you all to do the work for me).

This program could lead to a government policy that saves lives, so it is an important program.

Thanks again.
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

The problem I'm running into, is that there are some elements that won't show up at 1:625 resolution. Quarantine areas can be as small as 121 people so none of them would show up unless they cluster together.

ANY help in pointing me in the right direction is greatly appreciated. I'm not sure how to display 280 million virtual pixels in a display 448,000 small.

PB is great and so it this forum!!

Thanks.
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

This still sounds like too much data.

What is the final desired output? What are you trying to achieve in the images. That is, what will the (various stages of your) image depict? In (word) pictures?

It sounds like something that can be represented by graphs.

Or a map of the US zoned with colours representing % population that are diseased by location?

Anyhow, if you know what the picture(s) will look like, and can describe them here, we have a shot of helping.
@}--`--,-- A rose by any other name ..
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

As you'll have to make zooms, I don't think creating 8192x8192 images would be the best choice.

Moreover as you'll have (you really want it???) to make computation on each person (simply change his state based on its neighbours for example).

The best thing to do (in my opinion) is to create an array of 28 millions (or several little arrays stored on disk), and display 800*560 pixels by picking data in it. To make a zoom, you only have to pick 1 person on 2, 3, 4 etc. (you can make an average too, but this need some work, believe me ;) ).
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

The images will be just a retangle 800 by 560 with pixels in various colors. We don't have data that would allow us to represent the geographical spread of a disease. The rectangle is just a simulation.

Each pixel will represent 625 people in the calculations. The pixels will change colors for each render slide as the disease spreads.

That's all I'm trying to do, but I'm not sure how to represent 280 million in such a small resolution.
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

I don't follow you anymore!

If you have 625 people by pixel, 800 pixels by 560 pixels image is representing 280 millions people as you want.

So where is the problem? You want to make a zoom? As you don't have data, just duplicate the pixels!
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi PB&J Lover,

So the real thing is to work out how many pixels represent people who are sick (sick / 625) and how many are not (healthy / 625) and then fill in the image with, say, (sick / 625) red and (healthy / 625) green dots?

With snapshots over time to show how the disease is spreading? Until the entire screen is red? (We hope not in RL!)

Your input data is what? A date, a number of sick people and a number of healthy people per record?
@}--`--,-- A rose by any other name ..
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

Yes, that pretty much it. There are other colors like black for deaths and yellow quarantine areas, but that's essentially it.

I'm just not sure how to do this mechanically. If I do the calculations on the full population, how would I store the data for the next day/rendering? How exactly would you reduce the resolution evenly? Are zooms possible?

I had originally thought I could render the 280 million pixel image, but let the computer's own zoom in/out abilities take care of the rest.

Is that possible? Any ideas would help.
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

If I understand your requirements correctly: forget about the image until you have figured out how to manage your data in hiearchy. You will most likely generate the (constrained) image based on a level in your hierarchy, ie, a scaling factor. Based on the scaling factor dynamically generate a dataset then generate the image.

PS: Like any model you have to decided to what level of detail you want to simulate. If you want to "zoom-in" to any great degree and actually see more detail then you are increasing the amount of diskspace and processing you need to achieve it.
Last edited by dmoc on Mon May 08, 2006 3:22 pm, edited 1 time in total.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

My thought is:

First, flush the 280 million, it is skewing your thinking.

Perhaps think percentages instead.

Get the %ages of healthy, sick, quarantined, dead, fled, whatever and convert them (total_image_area_in_pixels * %something) into numbers.

Then colour in the image using those numbers. Simplistically, just loop for each category, plotting a pixel. Slow but ..
@}--`--,-- A rose by any other name ..
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

A faster way to fill the screen would be with rectangles using PureBasic's Box().

Another thought (using numbers I can manage). Say your image was 10 x 10 pixels, 100 in all. Say after converting, you ended up with 67 x green, 27 x yellow and 5 by red pixels.

First, your missing pixel (lost in the percentages): Add to the largest. So 68 red, 27 yellow, 5 red.

Next, knowing the image size, work out against your largest sample the best box you can. So box of 6 lines (6x10). Draw it. Then LineXY the remaining 8 greenies.

Take your next largest sample (27) and finish the line, so 2 pixels used. Leaving 25 and then repeat as above from the next line (box of 2 deep).

Repeat for each sample until done.

If you provide some code for that (or any approach) I think the top-gun optimisers on this forum will quickly come up with good ways to speed things up.

Success to you.
@}--`--,-- A rose by any other name ..
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

What I think I may need to do is run the simulation in a cube (800 x 560 x 625). That gets me my 280 million. Then perhaps I'll have to average the pixel colors in each cubic row and as if I was looking at it from the side.

Does PB do 3 dimensional arrays? :shock:

Thanks
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

:)

Just out of curiosity, why is it so important to have 1 pixel per person?

If, say, over 270 million people are healthy, you have a huge amount of, say green, to zoom into showing - more green.

Isn't going into something that big in such detail a bit like touring the US and talking to each person? Too many trees, can't see the forest?

But I'm only guessing at what you need, you actually know.

Success to you. :)
@}--`--,-- A rose by any other name ..
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Post by PB&J Lover »

No, I think you are right. The constraint is from the theoritician. His data is for the whole population, but I think we'll need to just work with a 448,000 sample or average every 625 people into one pixel.

I just thought that PB might have some magic game-related graphic gadget that would make this easy.

Can PB only do 2 dimensional arrays?
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Depends what you mean. An array with three dimensions A(a, b, c) or a layered array, which might be possible using a structured array (with [] elements in the structure).

But check out code by Comtois, including his cube, maybe some ideas there? He has the best Engine3D samples on these boards.

Lol, this is waaaaay too advanced for me! :)
@}--`--,-- A rose by any other name ..
Post Reply