Page 1 of 2

median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-22T04:45:19-07:00
by jmaroza
Hi,

I have been (unsuccesfully) searching for a script to compute an image as the median of a rather large sequence of images, operating pixel-by-pixel. That is, every resulting pixel should be (in graylevel or luminance or any other 1-dimensional measure) the median of pixels in te same position along the sequence.

Does anybody know how to do it?

Thanks in advance,

José.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-22T11:11:56-07:00
by fmw42
Post a suggestion to the Developers forum to add median as an option to -evaluate-sequence, which can already do mean, min, max for each pixel over a sequence of images. Standard Deviation might also be useful

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-22T13:17:33-07:00
by GreenKoopa
With a smallish, fixed number of images, or with a large or varying number of images?

Say your 1-dimensional measure was graylevel. Do you want your resulting image to be those graylevel values, or the color values that gave those graylevel measures? The former MAY be easier, and definitely would not be more difficult.

fmw42, is there a usage example using -evaluate-sequence, or a list of operator is may use?

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-22T16:04:42-07:00
by fmw42
fmw42, is there a usage example using -evaluate-sequence, or a list of operator is may use?
Presumably it can use most if not all of the -evaluate operators (convert -list evaluate). But I cannot be sure which ones actually make sense for such. All I know about are min,max,mean.

see the original discussion at viewtopic.php?f=1&t=15711&hilit=evaluate+sequence

orginally there was one -average which has now been deprecated by -evaluate sequence

note that min and max could be done using -compose lighten/darken -composite

Example

convert image1 image2 image3 ... imageN -evaluate-sequence mean result_mean_image

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-26T03:09:16-07:00
by jmaroza
GreenKoopa wrote:With a smallish, fixed number of images, or with a large or varying number of images?

Say your 1-dimensional measure was graylevel. Do you want your resulting image to be those graylevel values, or the color values that gave those graylevel measures? The former MAY be easier, and definitely would not be more difficult.

fmw42, is there a usage example using -evaluate-sequence, or a list of operator is may use?
Thanks to fmw42 and GreenKoopa for posting. What I need is to get the median image of a rather great number of them, may be up to 400 images, all 640x480.

-evaluate-sequence permits arithmetic and logical expressions to be evaluated pixel-by-pixel, but I have no idea on how to evaluate (640x480 times) the median of a series of 400 graylevels. Probably the task is far from being trivial, since it requires ordering 400 graylevels, pixel-by-pixel.

I'll suggest to developers to create the option, although I suspect that they have already thought on it, but it is not so easy.

Thanks to all,

José.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-26T20:04:42-07:00
by fmw42
Perhaps I misunderstood. I thought you wanted one resulting image of size 640x480 which had the median value at each pixel computed from 400 images. That is pixel 0,0 in the result is the median of pixel 0,0 from all of the 400 images, etc for each pixel location within the 640x480 coordinates. Is that not what you want?

Do you want the median of each image, then the median of all the medians?

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-28T02:13:48-07:00
by jmaroza
fmw42 wrote:Perhaps I misunderstood. I thought you wanted one resulting image of size 640x480 which had the median value at each pixel computed from 400 images. That is pixel 0,0 in the result is the median of pixel 0,0 from all of the 400 images, etc for each pixel location within the 640x480 coordinates. Is that not what you want?

Do you want the median of each image, then the median of all the medians?
Sorry for not explaining clearly and for my bad English. Yes, it is just what I need, fmw42. Pixel 0,0 of resulting image must be the median of pixel 0,0 from all the 400 images, an so on with remaining pixels. Since original images are coloured, a 1-dimensional measure must be taken, such as graylevel, or luminance, or chanel, or whatever.

An example of my work can be seen in http://aljayani.ujaen.es. It is a 24-hour webcam of the sky. It generates an image every minute. Due to the luminic contamination of the city, stars are dificult to see. However, if we substract from every image a model of the sky specific to the current time, then lots os stars appear, as well as the Milky Way. An example is shown by clicking on "Videogaleria", then in "La Via Lactea" (sorry, the web page is for didactic purposes and it is only in Spanish). The video has been created almost by hand. Every photogram is the difference of the original image and the model of the sky. The model is just the median of all original images in the range [-200minutes,+200minutes] with respect to the time of the original image. The result is spectacular. We would like to automatize this process and offer processed videos in the web.

I posted to developers. My post has been readed, but still no response.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-28T07:22:20-07:00
by magick
Install ImageMagick, version 6.6.6, and try -evaluate-sequence median.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-28T19:13:11-07:00
by anthony
The address http://aljayani.ujaen.es/ errors.
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 8
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 17
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 30
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\planisferio.php on line 208

I would love to see these 'webcam stars'. I have taken photos of the night sky using long exposures (not really very long) on a digital camera from my backyard.

Original image from camera (very dark)
http://www.ict.griffith.edu.au/~anthony ... ht_sky.jpg

After some simple contrast enhancement (Greens became too bold but it basically worked)

Code: Select all

  convert night_sky.jpg -strip -resize 800x600 \
          -sigmoidal-contrast 15,0% night_sky_enhanced.jpg
Image
Yes the house is my neighbour! And yes that is the southern cross near the top, as I do live in the land 'Down Under'.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T00:56:05-07:00
by jmaroza
magick wrote:Install ImageMagick, version 6.6.6, and try -evaluate-sequence median.
With Imagemagick 6.6.6-0 2010-11-21 Q16:

...> convert *.jpg -evaluate-sequence median out.jpg

Magick: unrecognized evaluate operator `median' @ error/convert.c/ConvertImageCommand/1388

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T01:00:10-07:00
by jmaroza
anthony wrote:The address http://aljayani.ujaen.es/ errors.
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 8
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 17
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\index.php on line 30
PHP Warning: gethostbyaddr(): Address is not a valid IPv4 or IPv6 address in C:\Inetpub\wwwroot\planisferio.php on line 208
Nice photo!

Unexpected error. No user had reported it before. I'll try to debug. Please try again. I have put an "@" before gethostbyaddress to avoid strange messages.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T06:03:26-07:00
by jmaroza
I've seen a new version 6.6.6-1 including support for -evaluate-sequence median. Thanks to developers for being so diligent!.

Unfortunately, downloaded pack ImageMagick-6.6.6-1-Q16-windows-dll.exe still has a convert.exe reporting 6.6.6-0 version. Am I doing something wrong?

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T06:36:08-07:00
by magick
Version 6.6.6-0 supports the -evaluate-sequence median as well. Give it a try.

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T10:55:56-07:00
by jmaroza
magick wrote:Version 6.6.6-0 supports the -evaluate-sequence median as well. Give it a try.
$magick>convert *.jpg -evaluate-sequence median out.jpg

Magick: unrecognized evaluate operator `median' @ error/convert.c/ConvertImageCommand/1388

Perhaps I'm doing something wrong?

Re: median of a sequence of images operating pixel-by-pixel

Posted: 2010-11-29T11:23:41-07:00
by magick
Ok, we'll need to build ImageMagick 6.6.6-1 for Windows and release it. We'll need a few days.