image generation in C++

Discussion in 'C++' started by nvinhphu@gmail.com, Jun 16, 2008.

  1. Guest

    Dear all,

    I would like to generate images like the ones in the right column at
    this link
    http://www.micthemodel.org/pages/examples.html (Sorry but I can not
    post
    attachment).

    These images are in fact 2D slices of a 3D image of a cube containing
    a set
    of layered spheres. A layered sphere is a set of concentric spheres of
    different
    colors (called grains). So, in my program, I have the coordinates of
    the center of the grains, its radii and the colors of each layers.

    As the easiest way, I have used the Povray (www.povray.org/) program
    by writing my grains data to text file of format required by Povray.
    With this way, I can generate image of up to about 3000 grains. More
    than that, the tracing progress of Povray is so slow.

    I have therefore been looking for other more effective approaches. The
    first one is to use a free C++ image library that can write images
    containing spheres. The second way is to write my data to pixels.

    My question is how to realize these two ways in real C++ code. Please
    help me.

    Many thanks in advance.

    Phu
     
    , Jun 16, 2008
    #1
    1. Advertising

  2. Jerry Coffin Guest

    In article <d1ad669a-040f-4182-94fb-191ea939cd89
    @a1g2000hsb.googlegroups.com>, says...

    [ ... ]

    > These images are in fact 2D slices of a 3D image of a cube containing
    > a set of layered spheres. A layered sphere is a set of concentric
    > spheres of different colors (called grains). So, in my program, I
    > have the coordinates of the center of the grains, its radii and the
    > colors of each layers.
    >
    > As the easiest way, I have used the Povray (www.povray.org/) program
    > by writing my grains data to text file of format required by Povray.
    > With this way, I can generate image of up to about 3000 grains. More
    > than that, the tracing progress of Povray is so slow.
    >
    > I have therefore been looking for other more effective approaches. The
    > first one is to use a free C++ image library that can write images
    > containing spheres. The second way is to write my data to pixels.
    >
    > My question is how to realize these two ways in real C++ code. Please
    > help me.


    A great deal depends on what you really want. If you want to produce a
    display (especially an interactive display), the answer is quite a bit
    different than if you want to produce a bitmap file of some sort.

    If you want produce an (interactive) display, you probably want to use
    something like OpenGL. This will allow you to send your data to the
    display as a set of items with 3D coordinates. You can then pick an
    angle of view and coordinates of the slice you want to view, and it'll
    produce a display of that part of the data visible from that point.

    If you want to produce an output file, you can create a 3D volume as
    (for example) a three dimensional array (or some sort of matrix) of
    numbers signifying the color at any given spot in the volume. Be aware
    that this step can take a great deal of memory. Picking a slice from
    that consists of reading the colors from the matrix where it intersects
    a plane of your choosing. You'll typically pick that plane in terms of
    polar coordinates (i.e. its angles with respect to some origin) and then
    convert to individual pixel coordinates using sine and cosine. If you're
    concerned with speed, you can also do a version of something like
    Bresenham's algorithm, but for a plane instead of a line.

    Of course, from that point you'll need to convert the individual pixel
    values into a readable file format, but that's mostly a matter of
    finding documentation on your format of choice, and writing the
    appropriate "stuff" into the header and such, then writing out the
    values of the individual pixels. Of course some formats (e.g. JPEG) do
    lossy compression on the pixels, but they're probably not very suitable
    for your purposes -- from the looks of things, something like RLE or LZ*
    compression should work quite well.

    --
    Later,
    Jerry.

    The universe is a figment of its own imagination.
     
    Jerry Coffin, Jun 16, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    3
    Views:
    554
    Steven Cheng[MSFT]
    Jul 1, 2004
  2. =?Utf-8?B?cGJi?=

    Dynamic Image Generation Service VB 1.1

    =?Utf-8?B?cGJi?=, Feb 15, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    358
    =?Utf-8?B?cGJi?=
    Feb 15, 2005
  3. Victor Irzak

    Image Generation Service

    Victor Irzak, Sep 26, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    886
    Victor Irzak
    Sep 29, 2005
  4. Waverider
    Replies:
    1
    Views:
    211
    JuanDG
    Sep 21, 2004
  5. John W. Long

    HTML Generation (Next Generation CGI)

    John W. Long, Nov 22, 2003, in forum: Ruby
    Replies:
    4
    Views:
    376
    John W. Long
    Nov 24, 2003
Loading...

Share This Page