File:Line scanning animation.gif
Original file (620 × 860 pixels, file size: 1.73 MB, MIME type: image/gif, looped, 150 frames, 9.9 s)
Captions
Summary
[edit]DescriptionLine scanning animation.gif |
Deutsch: Animation des Funktionsprinzips einer Zeilenkamera mit bewegten Sensor. |
Date | |
Source | Own work |
Author | Laserlicht |
Create Gif with ImageMagick: convert -delay 3 video.tiff -set dispose background -coalesce -layers Optimize video.gif |
Pause from first and last frame manually edited with GIMP |
Code
[edit]#Path to Cairo Lib
import os
os.environ["PATH"] = r"D:\Programme\msys64\mingw64\bin" + os.pathsep + os.environ["PATH"]
#Imports
import drawSvg as draw
from PIL import Image
import requests
from io import BytesIO
import numpy as np
import webbrowser
#Global Settings
url = "https://upload.wikimedia.org/wikipedia/commons/8/8c/Glockenkelter_Stetten_i.R.jpg"
bmp_size = (3000, 2000)
scan_size = (75, 50)
submove = 2
#Image
response = requests.get(url, headers={"User-Agent": "PythonImage/0.0 (https://www.python.org/; python@noreply.org) generic-library/0.0"})
im = Image.open(BytesIO(response.content))
im = im.resize(bmp_size, Image.ANTIALIAS)
im_byte_arr = BytesIO()
im.save(im_byte_arr, format='PNG')
#Scanned Image
im = im.resize(scan_size, Image.ANTIALIAS)
pix = np.array(im)
pix = np.transpose(pix, (1, 0, 2))
def render(f):
#Settings / Objects
size = (620, 860)
d = draw.Drawing(size[0], size[1], origin=(0, 0), displayInline=False)
d.append(draw.Rectangle(0, 0, size[0], size[1], fill="#ffffff", fill_opacity=1.0))
#Calculations
gap = (600 / pix.shape[0], 400 / pix.shape[1])
radius = min(gap[0], gap[1]) / 2
x_move = (gap[0] / submove) * f
scan_pos = f / submove
#Image
d.append(draw.Image(10, 10 + 30, 600, 400, data=im_byte_arr.getvalue(), mimeType="image/png", embed=True))
d.append(draw.Rectangle(10, 10 + 30, 600, 400, stroke="#000000", stroke_width=2, fill_opacity=0.0))
#Scanned Image
d.append(draw.Rectangle(10, 10 + 30 + 400 + 10, 600, 400, stroke="#000000", stroke_width=2, fill_opacity=1.0))
for x in range(pix.shape[0]):
for y in range(pix.shape[1]):
color = (pix[x][y]).astype(int)
if scan_pos < x - 2: color[0] = 0
if scan_pos < x - 1: color[1] = 0
if scan_pos < x: color[2] = 0
color = tuple(color)
color = '#%02x%02x%02x' % color
d.append(draw.Circle(10 + x * gap[0] + radius, 10 + 30 + 400 + 10 - y * gap[1] - radius + 400, radius, fill=color))
d.append(draw.Rectangle(10, 10 + 30 + 400 + 10, 600, 400, stroke="#000000", stroke_width=2, fill_opacity=0.0))
#Scanline
d.append(draw.Rectangle(10 - 5 + x_move - radius, 5, 5 * gap[0], 440, stroke="#000000", stroke_width=2, fill_opacity=0.0))
for x in range(3):
color = '#%02x%02x%02x' % [(0, 0, 255), (0, 255, 0), (255, 0, 0)][x]
d.append(draw.Circle(10 + gap[0] + x * gap[0] + radius - 5 + x_move - radius, 30, radius, fill=color))
for y in range(pix.shape[1]):
stroke = 2
d.append(draw.Rectangle(10 + gap[0] + x * gap[0] + x * stroke - stroke - 5 + x_move - radius, 10 + 30 + y * gap[1], 2 * radius, 2 * radius, stroke=color, stroke_width=stroke, fill_opacity=0.0))
d.append(draw.Text("Sensor", 10, 10 + gap[0] * 2 + radius - 5 + x_move - radius, 15, center=True))
#Output
d.setRenderSize(size[0], size[1])
return d
#Render to Images
with draw.animate_video("video.tiff", render) as anim:
for i in range(scan_size[0] * submove):
anim.draw_frame(i)
#Render to SVG/PNG
#d = render(0)
#d.saveSvg("a.svg")
#d.savePng("a.png")
#View
#webbrowser.open('file://' + os.path.realpath("video.tiff"))
#input()
Licensing
[edit]Image:
- 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.
Source:
This file is licensed under the Expat License, sometimes known as the MIT License:
Copyright © Laserlicht Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software. To uploader: MIT License has various versions, you may want to specify the license more precisely. Click {{MIT}} to see details.
http://opensource.org/licenses/mit-license.phpMITMIT licensetruetrueLaserlicht |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 18:13, 13 November 2021 | 620 × 860 (1.73 MB) | Laserlicht (talk | contribs) | Anordnung | |
17:56, 13 November 2021 | 1,230 × 450 (1.89 MB) | Laserlicht (talk | contribs) | lower Framerate for Thumb | ||
17:42, 13 November 2021 | 1,230 × 450 (2.81 MB) | Laserlicht (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 2 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on de.wikipedia.org
- Usage on en.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
GIF file comment | created by Michael H. (aka "Laserlicht" on Wikimedia Commons) |
---|