POV-Ray : Newsgroups : povray.off-topic : Merge hundreds of images together? Server Time
4 Sep 2024 03:19:08 EDT (-0400)
  Merge hundreds of images together? (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Darren New
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 14:10:44
Message: <4c2e2ba4$1@news.povray.org>
Shay wrote:
> Average.

If it's really hundreds of images, to the point where simply averaging them 
together fails due to lack of sufficiently deep alpha channels (or some 
such), then the best bet is probably to find NetPBM (aka PBMPlus) and turn 
them all into textual PPM files. (Actually, I suspect ImageMagick can turn 
any file into a PPM file too, for that matter.)

Then write a simple program that reads all the files, does the average with 
longs instead of integers, and then writes out a PPM file you can turn back 
into whatever format you want to use.

If you use the textual version of PPM, you can open it in a text editor and 
deduce the format pretty easily, if you don't want to track down the actual 
specs.

-- 
Darren New, San Diego CA, USA (PST)
    C# - a language whose greatest drawback
    is that its best implementation comes
    from a company that doesn't hate Microsoft.


Post a reply to this message

From: Darren New
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 14:16:22
Message: <4c2e2cf6$1@news.povray.org>
Darren New wrote:
> If you use the textual version of PPM, you can open it in a text editor 

convert xyz.png -compress None xyz.ppm

Then edit xyz.ppm in a text editor. You'll get a header (P3), the X, Y, and 
maximum data value, then X*Y ascii integers.

Read em, average em, convert em back.

-- 
Darren New, San Diego CA, USA (PST)
    C# - a language whose greatest drawback
    is that its best implementation comes
    from a company that doesn't hate Microsoft.


Post a reply to this message

From: Warp
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 14:26:51
Message: <4c2e2f6b@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Why not use POV-Ray for the job?

  Has the limit of 256 elements in a pigment map (and other types of map)
been removed?

-- 
                                                          - Warp


Post a reply to this message

From: Kevin Wampler
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 17:34:11
Message: <4c2e5b53$1@news.povray.org>
Shay wrote:
> Warp wrote:
>> Shay <sha### [at] nonenone> wrote:
>>> Using Linux?
>>
>>> A BIT on-topic; Pictures produced using POV animation.
>>
>>> composite frame0.png frame1.png ...... frame9.png merged.png
>>> gives a poor result.
>>

I wrote a utility to do this a while back (but I'm on vacation so 
unfortunately I won't be able to find and post it for a while).  At any 
rate, the trick was to average pairs of images in a binary tree pattern 
until you're left with a single image at the root.  In this way you 
avoid the problems with limited precision that you get using the naive 
approach.  So long as you have a utility to average a pair of images it 
should be easy to write a script to do this.


Post a reply to this message

From: Darren New
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 17:55:30
Message: <4c2e6052@news.povray.org>
Kevin Wampler wrote:
> the trick was to average pairs of images in a binary tree pattern 

I think that's only going to work if you have a number of images that's a 
power of two. Certainly merging 3 images this way isn't going to balance them.

-- 
Darren New, San Diego CA, USA (PST)
    C# - a language whose greatest drawback
    is that its best implementation comes
    from a company that doesn't hate Microsoft.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 21:03:23
Message: <4c2e8c5b$1@news.povray.org>
Darren New wrote:
> Kevin Wampler wrote:
>> the trick was to average pairs of images in a binary tree pattern 
> 
> I think that's only going to work if you have a number of images that's 
> a power of two. Certainly merging 3 images this way isn't going to 
> balance them.
> 


I think I also kept track of a weight for each image to account for 
that, but it's a good point that I should have mentioned.


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Merge hundreds of images together?
Date: 2 Jul 2010 21:26:59
Message: <4c2e91e3$1@news.povray.org>
clipka wrote:
> Am 02.07.2010 18:26, schrieb Shay:
>> Using Linux?
>>
>> A BIT on-topic; Pictures produced using POV animation.
>>
>> composite frame0.png frame1.png ...... frame9.png merged.png
>> gives a poor result.
> 
> Why not use POV-Ray for the job?

A dedicated tool wouldn't need to load all images into RAM before starting.


Post a reply to this message

From: Shay
Subject: Re: Merge hundreds of images together?
Date: 3 Jul 2010 11:39:01
Message: <4c2f5995$1@news.povray.org>
On 07/02/2010 01:16 PM, Darren New wrote:
> Darren New wrote:
>> If you use the textual version of PPM, you can open it in a text editor
>
> convert xyz.png -compress None xyz.ppm
>
> Then edit xyz.ppm in a text editor. You'll get a header (P3), the X, Y,
> and maximum data value, then X*Y ascii integers.
>
> Read em, average em, convert em back.
>

I should have thought of this; I have written code in Python for 
handling PPMs. Only problem is that I have to make and format a list of 
the files so that Python can read the list. My Python skills are not 
such that I can call a Python program with program(args). Still, a Vim 
script should make quick work of that.

Shouldn't need longs. Hope not, at least, I've got no idea how to deal 
with them in Python.

  -Shay


Post a reply to this message

From: Aydan
Subject: Re: Merge hundreds of images together?
Date: 7 Jul 2010 11:55:01
Message: <web.4c34a1ee7dfe797f3771cd8e0@news.povray.org>
> I should have thought of this; I have written code in Python for
> handling PPMs. Only problem is that I have to make and format a list of
> the files so that Python can read the list. My Python skills are not
> such that I can call a Python program with program(args). Still, a Vim
> script should make quick work of that.
>
> Shouldn't need longs. Hope not, at least, I've got no idea how to deal
> with them in Python.
>
>   -Shay

import os
import sys
path=sys.argv[1]
filelist=os.listdir(path)
#print the file list:
print "\n".join(filelist)
for filename in filelist:
  if os.path.isfile(filename):
    #do whatever

and start your script with the folder as a parameter, e.g. ./foo.py
/home/usr/blah


Post a reply to this message

From: Shay
Subject: Re: Merge hundreds of images together?
Date: 7 Jul 2010 13:50:26
Message: <4C34BE74.3080803@n.n>
Thank you.

On 07/07/2010 10:49 AM, Aydan wrote:
> import os
> import sys
> path=sys.argv[1]
> filelist=os.listdir(path)
> #print the file list:
> print "\n".join(filelist)
> for filename in filelist:
>    if os.path.isfile(filename):
>      #do whatever


Post a reply to this message

<<< Previous 5 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.