File:Rolling shutter effect animation.gif

Rolling_shutter_effect_animation.gif (400 × 200 pixels, file size: 139 KB, MIME type: image/gif, looped, 60 frames, 6.0 s)

Summary

Description
English: The effect of a rolling shutter on a spinning disc simulated. The jagged appearance is due to the small number of rows; the higher number of rows in a real camera results in smoother curves.
Date
Source
Rolling shutter effect.svg
Author cmglee

Python source

The frames were rendered using Python 2 with pypng below, converted to GIF, made into a GIF animation, and optimised with Ezgif.

#!/usr/bin/env python
import png, math, os, functools, operator

def draw_pixel(pixelsss, x, y, rrggbb):
 pixelsss[y][x][0] = int(rrggbb[-6:-4], 16)
 pixelsss[y][x][1] = int(rrggbb[-4:-2], 16)
 pixelsss[y][x][2] = int(rrggbb[-2:  ], 16)
def write_png(path, pixelsss, width, height=None, alpha=False):
 print('> %s' % (path))
 f_out = png.Writer(width=width, height=width if height is None else height, alpha=alpha)
 return f_out.write_array(open(path, 'wb'),
         functools.reduce(operator.iconcat,
         functools.reduce(operator.iconcat, pixelsss, []), []))
def compute_colour(fraction, deg):
 return colours[int((deg + 720 - 360 * fraction + 0.5) / 60) % 6]

n_frame  = 60
w_frame  = 400
h_frame  = 200
radius   = 99
w_frame2 = w_frame // 2
diameter = radius  *  2
colours  = ['ff0000','cc9900','00cc00','3399ff','6666ff','cc33ff']
basename = os.path.splitext(os.path.basename(__file__))[0]
cumulsss = [[[255 for c in range(3)] for x in range(diameter)]
                                     for y in range(diameter)]
for i_frame in range(n_frame + 1): ## 0 = prepare cumulative image
 framesss = [[[255 for c in range(3)] for x in range(w_frame)]
                                      for y in range(h_frame)]
 for y in range(-radius, radius):
  out_y     = y + radius
  out_y_end = (diameter - 1) * i_frame // n_frame
  for x in range(-radius, radius):
   if x * x + y * y < radius * radius:
    out_x = x + radius
    deg   = math.degrees(math.atan2(y, x))
    colour_cumul = compute_colour((y + radius + 1.0) / (diameter - 1), deg)
    colour_disc  = compute_colour(float(i_frame)     / n_frame       , deg)
    if i_frame > 0: draw_pixel(framesss, out_x + 1, out_y, colour_disc )
    else:           draw_pixel(cumulsss, out_x    , out_y, colour_cumul)
  if out_y <= out_y_end: framesss[out_y][w_frame2:w_frame2 + diameter] = cumulsss[out_y]
  for dy in [-1, 0]:
   framesss[out_y_end + dy][1] = framesss[out_y_end + dy][w_frame - 2] = [0,0,0]
  for dy in [-2, 1]:
   framesss[out_y_end + dy][1:w_frame - 1] = [[0,0,0] for i in range(w_frame - 2)]
 if i_frame > 0:
  write_png(r'F:\%s\%02d.png'  % (basename, i_frame), framesss, w_frame, h_frame)
 else:
  write_png(r'F:\%s\00.png' % (basename), cumulsss, diameter, diameter)

Licensing

w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

16 October 2013

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current02:28, 23 May 2025Thumbnail for version as of 02:28, 23 May 2025400 × 200 (139 KB)CmgleeIncrease framerate to 10 fps
02:04, 23 May 2025Thumbnail for version as of 02:04, 23 May 2025400 × 200 (56 KB)CmgleeCalculate every row in Python with png.py to reduce jaggies
17:34, 16 October 2013Thumbnail for version as of 17:34, 16 October 2013400 × 200 (109 KB)CmgleeUser created page with UploadWizard

Global file usage

The following other wikis use this file:

Metadata