for f in *.tiff ; do echo $f; doneExample with ImageMagick's convert program:
for f in *.tiff; do convert -crop 384x384+48+35 $f out/$f; done
i.e. some stuff and junk about Python, Perl, Matlab, Ruby, Mac X, Linux, Solaris, ...
for f in *.tiff ; do echo $f; donefor f in *.tiff; do convert -crop 384x384+48+35 $f out/$f; done
def mail(From,To,subject,msg):
import smtplib
smtpserver = 'localhost' # SMTP server
AUTHREQUIRED = 0 # if you need to use SMTP AUTH set to 1
smtpuser = '' # for SMTP AUTH, set SMTP username here
smtppass = '' # for SMTP AUTH, set SMTP password here
RECIPIENTS=To
SENDER=From
mssg = """"\From: %s
Subject: %s
%s
""" %(SENDER,subject,msg)
session = smtplib.SMTP(smtpserver)
if AUTHREQUIRED:
session.login(smtpuser, smtppass)
smtpresult = session.sendmail(SENDER, RECIPIENTS, mssg)
session.quit()
if __name__ == '__main__':
subject="This is some email subject"
mssg='This is content of the mail.'
mail("return@address.com","destination@address.com",
subject,mssg) Note: this code is based on the this article.
| function plotDiff2D() %p. 351, eg. 1 t=[-2:0.1:2]; cT=[-2:.5:2]; for c1=cT for c2=cT x1=c1*exp(3*t)+c2*exp(-t); x2=c1*2*exp(3*t)-2*c2*exp(-t); lineS='b-'; if c1==0 || c2==0, lineS='r-'; end hold on; plot3(x1,x2,t,lineS); end end limm=6 xlim([-limm limm]);ylim([-limm limm]); %axis square xlabel('x1'); ylabel('x2'); zlabel('t'); grid on; |
Whats more, the problems with eigenvalues that I had with Python (see this post) does not exist in Octave 3. I have to say, that for now I have been working only with eigenvalues, inverse matrices, and multiplication of matrices. But I am encourge to use Octave 3 for longer, to other tasks, and we will see what will happen.
from scipy import *
from scipy.linalg import *
A=matrix([ [-5,-5,-9],[8,9,18],[-2,-3,-7] ])
print eigvals(A)
# [-0.999989 +1.90461984e-05j -0.999989 -1.90461984e-05j
# -1.00002199 +0.00000000e+00j]
A2=matrix([ [-5,-5,-9],[8,9,18],[-2,-3,-7] ])
print eigvals(A2)
# [-1.+0.j -1.00000005+0.j -0.99999995+0.j]from sympy import *
from sympy.matrices import Matrix
x=Symbol('x')
A=Matrix(( [-5,-5,-9],[8,9,18],[-2,-3,-7] ))
print roots(A.charpoly(x),x)
# Returns error!!!
A2=Matrix(( [-1,-3,-9],[0,5,18],[0,-2,-7] ))
print roots(A2.charpoly(x),x)
# Returns error!!!
A=[-5,-5,-9;8,9,18;-2,-3,-7]
eig(A)
ans =
-1.0000 + 0.0000i
-1.0000 - 0.0000i
-1.0000
A2=[-5,-5,-9;8,9,18;-2,-3,-7]
eig(A2)
ans =
-1.0000 + 0.0000i
-1.0000 - 0.0000i
-1.0000
import scipy as sc
p=sc.poly1d([-1,-3,-3,-1])
print p= sc.roots(p)
# [-1.0000086 +0.00000000e+00j -0.9999957 +7.44736442e-06j
# -0.9999957 -7.44736442e-06j]
import sympy as sy
x=sy.Symbol('x')
print sy.solve(-x**3-3*x**2-3*x-1==0,x)
#[-1]
p=[-1,-3,-3,-1]
roots(p)
ans =
-1.0000
-1.0000 + 0.0000i
-1.0000 - 0.0000i


#!/usr/bin/env python
'''
Convert tif images from Ludvig 2008.
This scripts take all tifs in input dir, and changes
tif files into tiff. Additionali it takes
right knee x-rays and flips them horizontally,
to have all x-ray in the same format.
'''
#from myUtil import *
import re
import os
import Image
import Tkinter, tkFileDialog, os.path
from scipy import *
def flip_horizontally(inDir,inFile,outFile=None):
imgpath=inDir+inFile
im = Image.open(imgpath)
out = im.transpose(Image.FLIP_LEFT_RIGHT)
if outFile is None: outFile=inFile
base=os.path.splitext(outFile)[0]
out.save(inDir+base+'_flopped.tiff')
def main():
inDir=myGetDir('./')
print inDir
files=os.listdir(inDir)
#change_file_ext(inDir,r'\.tif+$','.tiff')
for f in files:
if f.find('tiff')==-1: continue
if f.find('test')==-1: continue
print f
flip_horizontally(inDir,f,f)
def myGetDir(indir='./',putTitle='Select dir'):
"""Get one dir name"""
root = Tkinter.Tk()
root.withdraw()
dirr=tkFileDialog.askdirectory(initialdir=indir,
title=putTitle)
if len(dirr)==0: exit(1)
return dirr+'/'
if __name__ == '__main__':
main()

