You are here:
Foswiki
>
Cosmo Web
>
SRandGR
>
LorentzImage
(24 Apr 2018,
BoudRoukema
)
(raw view)
E
dit
A
ttach
<< Cosmo.WebHome %TOC% ---- ---+ Lorentz_image.sh ---++ packages needed * exiv2 * imagemagick <verbatim> #!/bin/bash ## Lorentz_image - transform an image file ## ## Copyright (C) 2013-2018 B. Roukema ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software Foundation, ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ## ## See also http://www.gnu.org/licenses/gpl.html ## Version 2018-04-24.0 if [[ ($# -eq 0) || ($# -ge 5) ]]; then echo "Usage: Lorentz_image.sh image [rapidity [Lorentz [outimage]]]" echo "If present, Lorentz must be either 1 (Lorentz) or 0 (rotation)." ##echo "e.g. Lorentz_image.sh IMAGE_FILENAME 1.0 1 new.png" exit 0 fi LANG=C IMAGE=$1 ## hardwired min/maximum PHI to avoid overstretching memory MAXPHI=1.5 MINPHI=-1.5 if [[ $# -ge 2 ]]; then PHI=$2 # convert from French/Polish decimal comma if [[ $(echo ${PHI}|grep ",") ]]; then NEWPHI=$(echo ${PHI}|sed -e 's/,/\./') PHI=${NEWPHI} fi # make sure |PHI| is not too big PHI=$(echo ${PHI} | awk -v maxphi=${MAXPHI} -v minphi=${MINPHI} '{print ($1 > maxphi)? maxphi : (($1 < minphi)? minphi : $1)}') else PHI=1.0 fi if [[ $# -eq 3 ]]; then DO_LORENTZ=$3 else # default DO_LORENTZ="1" fi if [[ $# -eq 4 ]]; then OUTIMAGE=$4 else OUTIMAGE="-" fi XSIZE=$(exiv2 ${IMAGE} 2>/dev/null |grep "Image size" |awk '{print $4}') YSIZE=$(exiv2 ${IMAGE} 2>/dev/null |grep "Image size" |awk '{print $6}') if [[ "${DO_LORENTZ}" -eq "1" ]]; then # cosh(phi) CPHI=$(echo ${PHI}|awk '{print 0.5*(exp($1)+exp(-$1))}') # -sinh(phi) SPHI1=$(echo ${PHI}|awk '{print -0.5*(exp($1)-exp(-$1))}') SPHI2="${SPHI1}" else # cos(phi) CPHI=$(echo ${PHI}|awk '{print cos($1)}') # +-sin(phi) SPHI1=$(echo ${PHI}|awk '{print -sin($1)}') SPHI2=$(echo ${SPHI1}|awk '{print (-1*$1)}') fi ## test #echo ${IMAGE} ${PHI} ${CPHI} ${SPHI} ${OUTIMAGE} && exit 0 convert ${IMAGE} -matte -virtual-pixel Transparent \ +distort AffineProjection ${CPHI},${SPHI1},${SPHI2},${CPHI},0,0 \ +repage ${OUTIMAGE} </verbatim> ---++ examples With <latex>-0.8 < \phi < 0.8</latex>, the Lorentz transformation gives: | *bicycle world sheet* | *La Joconde (Mona Lisa)* | | <img src="%ATTACHURLPATH%/bike_Lorentz.gif" alt="bike_Lorentz.gif" width='250' /> | <img src="%ATTACHURLPATH%/Joconde_Lorentz.gif" alt="Joconde_Lorentz.gif" width='250' /> | -- Main.BoudRoukema - 31 Mar 2016
Attachments
2
Attachments
2
Topic attachments
I
Attachment
Action
Size
Date
Who
Comment
gif
bike_Lorentz.gif
manage
113.4 K
31 Mar 2016 - 13:37
BoudRoukema
gif
Joconde_Lorentz.gif
manage
1113.0 K
31 Mar 2016 - 13:38
BoudRoukema
La Joconde (Mona Lisa) - Lorentz transform movie
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r2 - 24 Apr 2018,
BoudRoukema
Cosmo
Log In
or
Register
Toolbox
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
Cosmo
Main
Sandbox
System
English
Français
Polski
Copyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki?
Send feedback