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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
jmaroza

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

Post by jmaroza » 2010-11-22T04:45:19-07:00

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é.

User avatar
fmw42
Posts: 22468
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2010-11-22T11:11:56-07:00

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

User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post by GreenKoopa » 2010-11-22T13:17:33-07:00

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?

User avatar
fmw42
Posts: 22468
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2010-11-22T16:04:42-07:00

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

jmaroza

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

Post by jmaroza » 2010-11-26T03:09:16-07:00

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é.

User avatar
fmw42
Posts: 22468
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2010-11-26T20:04:42-07:00

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?

jmaroza

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

Post by jmaroza » 2010-11-28T02:13:48-07:00

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.

User avatar
magick
Site Admin
Posts: 10733
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2010-11-28T07:22:20-07:00

Install ImageMagick, version 6.6.6, and try -evaluate-sequence median.

User avatar
anthony
Posts: 8878
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post by anthony » 2010-11-28T19:13:11-07:00

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'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
http://www.imagemagick.org/Usage/

jmaroza

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

Post by jmaroza » 2010-11-29T00:56:05-07:00

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

jmaroza

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

Post by jmaroza » 2010-11-29T01:00:10-07:00

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.

jmaroza

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

Post by jmaroza » 2010-11-29T06:03:26-07:00

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?

User avatar
magick
Site Admin
Posts: 10733
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2010-11-29T06:36:08-07:00

Version 6.6.6-0 supports the -evaluate-sequence median as well. Give it a try.

jmaroza

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

Post by jmaroza » 2010-11-29T10:55:56-07:00

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?

User avatar
magick
Site Admin
Posts: 10733
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2010-11-29T11:23:41-07:00

Ok, we'll need to build ImageMagick 6.6.6-1 for Windows and release it. We'll need a few days.

Post Reply