Discussion:
Determining individual pixel color
Eric Schoeller
2010-05-07 20:36:59 UTC
Permalink
Hello,

I'm assembling a time lapse video from several thousand images.
Unfortunately, there was a problem with the camera and roughly half of
these images are shifted up on the X axis by several pixels (creating a
jitter). Instead of using fancy software such as Adobe After Effects,
I'd like to script something with image magick to identify which images
are shifted and then automatically "fix" these images. The problem I'm
having is identifying which ones are shifted. My initial thought was to
obtain the color of a certain reliable pixel in every image and use that
to determine which ones are shifted, however I can't seem to figure out
how to do that in image magick.

Is it possible? Is there are better approach?

Thanks!!

Eric Schoeller
Fred Weinhaus
2010-05-07 21:08:56 UTC
Permalink
Post by Eric Schoeller
I'm assembling a time lapse video from several thousand images.
Unfortunately, there was a problem with the camera and roughly half of
these images are shifted up on the X axis by several pixels (creating a
jitter). Instead of using fancy software such as Adobe After Effects,
I'd like to script something with image magick to identify which images
are shifted and then automatically "fix" these images. The problem I'm
having is identifying which ones are shifted. My initial thought was to
obtain the color of a certain reliable pixel in every image and use that
to determine which ones are shifted, however I can't seem to figure out
how to do that in image magick.
Is it possible? Is there are better approach?
IM has a compare function to compare two images or two single-pixel
images. see compare at
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/#compare

compare -metric rmse image1.png[1x1+10+10] image2.png [1x1+10+10] null:


will compare one pixel at position 10,10 from the upper left corner
and return the rmse difference.

you can also compare the whole images, but that is slower.


To fix it you would have to either subsection the odd image and fill
with black or some other color or roll the image and then fill with
black.

convert image1.png -crop NEWWIDTHxNEWHEIGHT+XOFF+YOFF -gravity xxx
-background black -extent OLDWIDTHxOLDHEIGHT +repage result.png

see
http://www.imagemagick.org/Usage/crop/#crop
http://www.imagemagick.org/Usage/crop/#extent

Loading...