I'm learning how to make gifs. Thread contains Goku
Parallax Skull

Parallax Skull

first one i've made in like a week. significantly edited down for length.

 
  • 1
Parallax Skull

Parallax Skull

@proof of concept Could you tell me more about how you went about doing the masking and fixing the background?

Meanwhile, just made this:

 
  • 1
proof of concept

proof of concept

waiting for the day the whole world fucking dies
@proof of concept Could you tell me more about how you went about doing the masking and fixing the background?

Meanwhile, just made this:

oh yeah whoops I forgot to do that over the weekend, but I'll get to it this evening
 
  • 1
proof of concept

proof of concept

waiting for the day the whole world fucking dies
, Last edited:
@Parallax Skull
OK so how I did the masking for my edit to your gif is pretty straightforward. I stumbled upon this just messing around last weekend and I don't know how much of this stuff is common knowledge, so if I'm saying a bunch of obvious stuff, well, :shrug: I used photoshop CS6, so the UI might be a bit different from your version, but I guarantee the tools are still there so you should be able to do this yourself without having to jump through any weird extra hoops.

The main tool I used to block out regions was the thresholding tool. You go to a layer, layer 15 in this example, click the button, and it generates a new layer that looks like this:


The pixels in the new layer are set to black or white depending on whether the corresponding pixels in the layer 15 fall below or above a certain threshold level that you can dynamically change with that slider. The default dimension of comparison against the threshold value is each pixel's grayscale intensity, but you can also threshold against a single color channel, or two out of the three color channels. I didn't get a screenshot of that menu but iirc you get to that selection by clicking on a tab that's obscured by the yellow tooltip above.

128 is the default threshold value. Lower it and you get more white:


Raise it and you get more black:


Since the threshold layer is binary, there are going to be large contiguous regions selectable with one click of the magic wand. The goal is to set the threshold so that you can select the region you want in as few clicks as possible. Luckily, animation tends to have foreground objects defined by sharp borders, typically in the form of actual black outlines, which helps us out a lot. In this image all the colors are pretty smooth and the way the characters enter and exit the frame makes it so that the rightmost part of their collective outlines forms a continuous foreground/background delimiter. For most frames I was able to set the threshold value such that I could select the entire sky region in a single click, then use that mask to delete those pixels in both the original frame and the duplicate frame in the second half of the gif.

Some frames are a bit more involved. For example, on frame 15 I couldn't get the threshold to work that well; here it is at 118.


The entire sky is white and the character outlines form a dividing line, but they're too thin, and the magic wand selection passes through them to select almost the whole image (all the selection work was done on the threshold layer; I switched the view back to the original frame here to make the selection boundary easier to see):



When that happens just set the threshold higher and clean up the noise with quick select and lasso.



For this frame the quick select took care of the pixels along the bottom of the moon, but kept eating the black border around gohan's hair spike, so I used the lasso there.

(The final gif has 2 frames with that exact mistake because I wasn't really paying close attention and didn't notice until after I'd exported and closed out of photoshop.)


You can leave in some sky pixels near the border and be fine, but if the border is missing in a bunch of frames it's pretty jarring.


This is the end product for that frame, and the corresponding duplicate in the second half of the gif:


At the end I went through and set layer 1 to be visible during every frame, and ta da, static background for the whole animation.

Some notes:
The starting point for my edit was your gif, so I was already working within a restricted color palette; if you're working from an imported mp4 with a wider range of colors you may have to fiddle with it more than I did to get the regions you want. Also, where this is useful is going to be very situational; obviously the gif I used is pretty ideal. In your gif where cell is thrashing away at android 17 with his tail you'd only be able to use it on the non-tail parts of cell in the first half of the gif. Your Dragon Ball Super gifs with all the cgi auras and camera shaking will be considerably tougher to use this on, and it might not be worth the effort, but doing it in certain spots might also save enough space to let you keep more of the color palette, so you're just going to have to play around with it to be sure.

Another note: thresholding against a single color channel as opposed to grayscale may or may not be that useful; pixels defined by RGB tuples can be deceptive in that, just because a region looks more blue to the eye than its surroundings doesn't necessarily mean that the pixels in that region have a significantly different value in their blue color channel than ones in neighboring regions. For example, here is frame 15 with the red and green channels zeroed out:

The sky isn't much different from the characters, really. You just have to get a feel for how and when to use those options I guess.
 
  • 1
Parallax Skull

Parallax Skull

, Last edited:
@proof of concept Thanks for the effort post! I'll need to put some time into fully digesting all of that and being able to execute on it (Photoshop is pretty alien to me), so I'll do that when I'm not so bogged down at work. Magic wand alone without the threshold tool (didn't know about the latter) would have been hell.

I did this one yesterday. Originally it was longer, but the resulting file was way too big so I ended up just doubling the speed on the whole thing. Making shit go really fast is kind of my thing, so I think it worked out.

 
Parallax Skull

Parallax Skull

It's also one of the few gifs so far where I've used a fade effect. I'd like to make more some sophisticated use of effects down the road.
 
Parallax Skull

Parallax Skull

I say I'm bogged down with work but then I go ahead and spend 2 hours making this anyway



It's 3 seconds long (I try to stick to around 2) with a lot of motion and shot transitions, so optimizing the colors/size was a lot of work. So was the video editing. Anyway that's my gif for today unless I'm insane and make another.
 
  • 1
Parallax Skull

Parallax Skull

Also see if you can spot where I used a fade on that one.
 
proof of concept

proof of concept

waiting for the day the whole world fucking dies
Also see if you can spot where I used a fade on that one.
looks like you used it to cheat the transition to goku's closeup
 
proof of concept

proof of concept

waiting for the day the whole world fucking dies
@proof of concept Could you tell me more about how you went about doing the masking and fixing the background?

Meanwhile, just made this:

can I get the source video for this one? I want to mess around with some other optimization ideas I have
 
proof of concept

proof of concept

waiting for the day the whole world fucking dies
also out of curiosity what version of photoshop do you use?
 
proof of concept

proof of concept

waiting for the day the whole world fucking dies
, Last edited:
I ran the frames of that gif through a canny edge detector to see if that might be another thing that could help with region selection/masking. I'll have to play with it a bit and also figure out how to do it in photoshop (I just ran it through matlab's built in tools with the default settings) but it looks promising. I put the output images back together into their own gif because it looks pretty neat:


edit: black-on-white might be easier to visually parse: