Rotating Animated GIF

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?".
Post Reply
DeadlyDad

Rotating Animated GIF

Post by DeadlyDad »

Basically, I am taking multiple pictures of an object while rotating it to (ultimately) create an animated GIF showing said object from all sides. Here is my first example:
Image

As you can see, while it looks pretty good, there is a lot of flickering going on. (At least part of it is because I am using just a hand-held lamp and the flash from my camera (Canon PowerShot SD450). Unfortunately, even with a good, bright, multi-point light source and the camera set to full manual, there is still some flickering. This example is just the worst.) This not only makes the picture look bad, there is no way to really optimize it. (Even at 120x160, it is over 430K! Ideally, the first frame should be the only one that needs to show the background.)

I've spent hours searching the forums and the web, but couldn't find an answer to my dilemma. There just doesn't seem to be a way to 'normalize' a series of images that I could find, either here, or in the documentation. The colours all seem fine; it's just the brightness that is out of whack. Is there any way of fixing this? (If I was just doing one or two, I would just do it by hand, but I'm helping my mother-in-law do hundreds, so it has to be automated.)

As I am the one taking the pictures, I could easily enough put a card with black/50% grey/white sections at the bottom of each picture. Is there a way to tell IM to use the levels at a particular location in the picture to adjust the brightness of the whole image?
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Re: Rotating Animated GIF

Post by dognose »

The two methods I'd suggest would both be in improving the pictures taken.

I would turn off the flash and use ambient light (maybe just outside light on a sunny day) This would get your camera to do less auto adjusting on the levels.

The other method would be to put it on a turntable and use movie mode. It could be a lot faster. again, this would need more ambient light as well.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating Animated GIF

Post by anthony »

If you can get your camera NOT to auto adjust. that would be better still. Some cameras come with options specifically for stop-frame animation. These take one frame at a time without auto-adjustments.

Also using a hand held light is not really a good idea.

Finally the other solution is to look at some 'constant' area of background in the image and adjust each frame to make that area 'constant brightness'. That should let you post-process the image to remove the flicker.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

I've done a lot of studying and trying different things, and I almost have the process figured out. I still have some tweaks to do on both the hardware & software end, but I'm almost there. This is one of my latest examples (before and after processing), created with a script that starts with a folder of pictures of the object (plus one of the empty background and one of the new background) and automatically creates an animated .GIF. One of the problems with this particular example is that my background (white) is too close to the majority of the object (also white) to be able to select a large enough fuzz factor to completely eliminate the background without also removing part of the object. Also, using the floodfill method doesn't work well if the object has holes. (Yes, I have other things I could have photographed, but I wanted to see what could be done with marginal cases.) Once I have the hardware and software perfected, I'll post some more images here, as well as putting together an Instructable.

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

Re: Rotating Animated GIF

Post by anthony »

The flash in the background pattern appears to be caused by the lighting flicker you were talking about earilier. That step may be vital.

Also yes it is a marginal case. and it may be better to always select the background for your rotation photos to be very different to the object itself.

There is also a minor jump in a few frame where the object appears to have lifted slightly higher than the rest. It may be camera movement or something else. You have to be very carefull with any stop-frame animation in this regard.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

Actually I think that the single flash 3/4 of the way through is just from me bumping the light cord. (DOH!) After I did a bit of research (...and RTFM...<_<'), I found out how to set my camera to full manual, so that took care of the flickering. I also have to come up with a different camera mount, as my current one isn't solid enough, and my particular camera doesn't support remote operation, so every time I take a picture there is a chance of moving the camera. I could have manually adjusted each picture to make them line up, but that would have been...you know...work! ;)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating Animated GIF

Post by anthony »

With stop-frame animation it is better to get the priginal pictures in the best possible way first. anything after that is a lot of work. Especially without any reference points to use to line things up using say the new distortion mapping methods (examples of which has yet to be created)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

I have been alternating between improving the hardware and working on the software, depending on my schedule. One problem I've noticed is digital noise. To deal with it (and the bounce caused by having to physically press the shutter button ), I set my camera to a five second delay, then to take ten shots in quick succession. I then have IM average them together. What especially gratified me was that not only was the noise toned right down, but fine detail was much improved. As my camera will hold more than 60 frames(@2592x1944) x 10 shots, this will work fine, albeit rather slow. :) After averaging at the full resolution, I can then drop the resolution down to 640x480 for animating. (I have a four-port KVM and plenty of old computers that can do the grunt work, and echo <CTRL-G><CTRL-G><CTRL-G> still works fine in a batch file to let me know when it is done - yeah, I know, but conversion to AutoIT will wait until after I have the process perfected.)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating Animated GIF

Post by anthony »

Well I am glad you solved the digital noise. Now if the dithering noise can also be solved, especially for the background, then you can get a very good GIF frame optimization for the animation as well.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

The project is currently on hiatus, as I am ill, but I'm checking eBay for a new camera that will support both CHDK and PSRemote, and still doing some research. One thing that has me very excited is a paper called A Bayesian Approach to Digital Matting, which can automatically convert this:
Image
to this:
Image

Would it be possible for one of you geniuses to add this to IM? I'll bake you some cookies! :D
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotating Animated GIF

Post by anthony »

probably better in a application wrapper around IM than IM itself, as there will be a lot of variables involved.

However without known exactly what is being done it will require quite a lot of work to do. If you like to do it, do it. If you have any programming skills at all you should find it a fascinating project, especially as you have a direct use for it yourself :-)

Basically there are too few of us actually programming, and those that are swamped with just things that either need to be done, or are of interest.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotating Animated GIF

Post by fmw42 »

With regard to your original question about uneven illumination correction, you could try my gaussian redist script to adjust each frame to the same gaussian histogram distribution. You can find the Unix bash script redist at
http://www.fmwconcepts.com/imagemagick/index.html
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

fmw42 wrote:With regard to your original question about uneven illumination correction, you could try my gaussian redist script to adjust each frame to the same gaussian histogram distribution. You can find the Unix bash script redist at
http://www.fmwconcepts.com/imagemagick/index.html
Wow! You have some great scripts. Unfortunately, I don't see how they can solve the problem inherent in animated .GIFs: the 256 color palette, and the fact that, even if two pictures in a row share the same palette, pixels may have separate index numbers that differentiate enough in value to cause a 'warbling' effect. (Zoom in on the white background or head of the bear to see what I mean.) I'm not even sure if it is possible to fix.

The only thing that I can think of to minimize it is to have a card that has pure white/black/red/green/blue squares on it placed so that it shows up in the bottom of each picture. (A 50% gray (or whatever) border on top would make it easier to set the limits for software.) Perform the histogram function, based on the card section, so that a specified percentage of each square is a pure color, then crop out the card section for the finished picture. That should ensure uniformity, no matter what the physical conditions are. Any chance you could come up with a script for that? I could see that it would help anyone struggling with getting their colors right in a studio setting.

[Edit: It just occurred to me; getting the proper 'pure' colors for your card could be as simple as grabbing a bunch of paint sample slips from a building supply store. Just scan a bunch until you find ones that are close enough to purity and glue them to a piece of cardboard.]
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Rotating Animated GIF

Post by el_supremo »

getting the proper 'pure' colors for your card could be as simple as grabbing a bunch of paint sample slips from a building supply store
The problem with that is that it would be difficult to find sample colours which have the correct reflectance and uniformity.
There are commercially prepared ones such as the Gretag-Macbeth colour checker cards which includes gray/black/white squares for simple colour balance and exposure, plus red/blue/green and skin tones.

Pete
DeadlyDad

Re: Rotating Animated GIF

Post by DeadlyDad »

el_supremo wrote:
getting the proper 'pure' colors for your card could be as simple as grabbing a bunch of paint sample slips from a building supply store
The problem with that is that it would be difficult to find sample colours which have the correct reflectance and uniformity.
There are commercially prepared ones such as the Gretag-Macbeth colour checker cards which includes gray/black/white squares for simple colour balance and exposure, plus red/blue/green and skin tones.
Pete
You haven't seen a paint slip display at a paint store recently, have you? :) Trying to find a fairly close Chroma Key match, I brought home a stack of cards an inch thick...and that's only cards that are close to green! No, finding a card that is 'close enough to purity', like I said, isn't a problem.

I agree that having a $100 piece of cardboard would help make for a perfectly leveled photo, but it doesn't need to be absolutely perfect, as this isn't for a professional, $20,000-a-shot studio. It is just to make setting levels easier, and, in my case, to ensure uniformity across a series of photos.
Post Reply