예제 #1
0
def process(input, position):
    size = len(input)
    output = copy.deepcopy(input)
    fft = DoubleFFT_1D(size)
    fft.realForward(output)
    for j in range(size/2):
        output[j]= Math.sqrt(Math.pow(output[2*j],2)+Math.pow(output[2*j+1],2));
    return output[:len(input)/2]
 def toBut(self, but):
   if but.x == 'abs':
     return but.y
   a = but.x - self.origin.x
   b = but.y - self.origin.y
   if a == 0 and b == 0:
     return rnd.nextDouble() * 360;
   if b < 0:
     return 180*Math.asin(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI+270
   else:
     return 180*Math.acos(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI
예제 #3
0
def longJumps(t, mindist):
  for nd in t.getRoot().getSubtreeNodes():
    if nd.parent is None:
      continue
    d = Math.sqrt(Math.pow(nd.x - nd.parent.x, 2) + Math.pow(nd.y - nd.parent.y, 2))
    if d > mindist:
      print nd.x, nd.y
      p = array([nd.x, nd.y], 'f')
      aff = t.affineTransform
      aff.transform(p, 0, p, 0, 1)
      cal = t.layerSet.getCalibration()
      print "Off:", p[0] * cal.pixelWidth, p[1] * cal.pixelHeight, (nd.layer.getParent().indexOf(nd.layer) + 1)
예제 #4
0
 def toBut(self, but):
     if but.x == 'abs':
         return but.y
     a = but.x - self.origin.x
     b = but.y - self.origin.y
     if a == 0 and b == 0:
         return rnd.nextDouble() * 360
     if b < 0:
         return 180 * Math.asin(
             a / Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2))) / Math.PI + 270
     else:
         return 180 * Math.acos(
             a / Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2))) / Math.PI
def bug_vector_y(percept, dist, scale, theta, p):
    r = percept.getRadius() / 2
    return (
        Math.sin(deg2pi(180 + self.towards(percept.getX() + r, percept.getY() + r)))
        * theta
        / Math.pow((dist / scale), p)
    )
예제 #6
0
def localContrast(im, block = 127, histobins = 256, maxslope = 3):
	ipMaskCLAHE = ByteProcessor(im.getWidth(),im.getHeight())
	ipMaskCLAHE.threshold(-1)
	bitDepth = im.getBitDepth()
	if bitDepth == 8:
		maxDisp = Math.pow(2,8) - 1
	else:
		maxDisp = Math.pow(2,12) - 1

	ip = im.getProcessor()
	ip.setMinAndMax(0,maxDisp)
	if bitDepth == 8:
		ip.applyLut()
	Flat.getFastInstance().run(im, block, histobins, maxslope, ipMaskCLAHE, False)
	del ipMaskCLAHE
	return im
예제 #7
0
def compute_heading():
    if (mvt_mem.direction == "EAST"):
        x_modifier = 2000
        y_modifier = 0
    elif (mvt_mem.direction == "WEST"):
        x_modifier = -2000
        y_modifier = 0
    elif (mvt_mem.direction == "SOUTH"):
        x_modifier = 0
        y_modifier = +2000
    elif (mvt_mem.direction == "NORTH"):
        x_modifier = 0
        y_modifier = -1000

    # on construit une liste de TOUS les objets  répulsifs
    repulsives = percepts.attackers.items () + \
                 percepts.explorers.items () + \
                 percepts.homes.items () + \
                 percepts.friends.items () + \
                 percepts.obstacles.items ()

    # valeurs magiques
    theta = 140
    scale = 25
    p = 2
    u = 30
    # composantes X et Y du vecteur direction final
    X = 0
    Y = 0
    if repulsives:
        for it, dist in repulsives:
            X = X + Math.cos(deg2pi(180 + self.towards(it.getX(), it.getY()))
                             ) * theta / Math.pow(dist / scale, p)
            Y = Y + Math.sin(deg2pi(180 + self.towards(it.getX(), it.getY()))
                             ) * theta / Math.pow(dist / scale, p)

    toterm("AFTER REPULSION:" + str(X) + " " + str(Y))
    X = X + Math.cos(deg2pi(self.getHeading())) * u
    Y = Y + Math.sin(deg2pi(self.getHeading())) * u
    toterm("AFTER ATTRACTION:" + str(X) + " " + str(Y))
    X += x_modifier
    Y += y_modifier
    toterm("NEW HEADING : " + str(self.towards(X, Y)))
    self.setHeading(self.towards(X, Y))
예제 #8
0
def NeighborChecker(xar, yar, zar, switch):
	""" Check the distance to neighbors, and count the number of neighbors below thdist. """
	global thdist
	neighborA = zeros('d', len(xar))
	if switch:
		for i in range(len(xar)):
			cx = xar[i]
			cy = yar[i]
			cz = zar[i]	 
			for j in range(len(xar)):
				if j != i :
					dist = Math.sqrt( Math.pow((cx - xar[j]), 2) + Math.pow((cy - yar[j]), 2))
					if dist < thdist:
						if Math.abs(cz - zar[j]) < 2:
							logstr = ".... Dot%d - Dot%d too close: dist = %d" % (i, j, dist)
							IJ.log(logstr)
							print logstr
							neighborA[i] += 1
			if neighborA[i] > 0:
				IJ.log("---> Dot%d rejected" % (i))
				print "---> Dot", i, " rejected"
	return neighborA
예제 #9
0
 def __init__(self, pointCounter=0):
     self.logger = LoggerFactory.getLogger("WaveformDataGenerator")
     self.channel = None
     self.useGaussian = False
     self.gaussian = None
     self.pointCounter = pointCounter
     self.incrementCounter = 1
     self.dataDecimalPlaces = 2
     self.roundingFactor = Math.pow(10.0, self.dataDecimalPlaces)
     self.gaussianPosition = 10.0
     self.gaussianWidth = 5.0
     self.gaussianHeight = 10.0
     self.noiseLevel = 0.1
     self.data = []
def bug_vector_y(percept, dist, scale, theta, p):
    r = percept.getRadius() / 2
    return Math.sin(
        deg2pi(180 + self.towards(percept.getX() + r,
                                  percept.getY() + r))) * theta / Math.pow(
                                      (dist / scale), p)
def vector_y(percept, dist, scale, theta, p):
    return Math.sin(deg2pi(180 + self.towards(percept.getX(), percept.getY()))
                    ) * theta / Math.pow((dist / scale), p)
 def distxy(self, ox, oy):
   return Math.sqrt(Math.pow(self.x-ox,2)+Math.pow(self.y-oy,2))
# the scale to be used for the downsampling
scale = 2

# set the tile sizes to be used
tileSizeX = 1024
tileSizeY = 1024

# setup reader
reader = ImageReader()
omeMeta = MetadataTools.createOMEXMLMetadata()
reader.setMetadataStore(omeMeta)
reader.setId(file)

# add resolution metadata
for i in range(resolutions):
    divScale = Math.pow(scale, i + 1)
    omeMeta.setResolutionSizeX(PositiveInteger(int(reader.getSizeX() / divScale)), 0, i + 1)
    omeMeta.setResolutionSizeY(PositiveInteger(int(reader.getSizeY() / divScale)), 0, i + 1)

# setup writer with tiling
writer = PyramidOMETiffWriter()
writer.setMetadataRetrieve(omeMeta)
tileSizeX = writer.setTileSizeX(tileSizeX)
tileSizeY = writer.setTileSizeY(tileSizeY)
writer.setId(outFile)
type = reader.getPixelType()

# create image scaler for downsampling
scaler = SimpleImageScaler()

# convert to Pyramidal OME-TIFF using tiling
# settings
file = "/path/to/inputFile.tiff"
outFile = "/path/to/outputFile.ome.tiff"
resolutions = 4
scale = 2

# setup reader and parse metadata
reader = ImageReader()
omeMeta = MetadataTools.createOMEXMLMetadata()
reader.setMetadataStore(omeMeta)
reader.setId(file)

# setup resolutions
for i in range(resolutions):
    divScale = Math.pow(scale, i + 1)
    omeMeta.setResolutionSizeX(PositiveInteger(int(reader.getSizeX() / divScale)), 0, i + 1)
    omeMeta.setResolutionSizeY(PositiveInteger(int(reader.getSizeY() / divScale)), 0, i + 1)

# setup writer
writer = OMETiffWriter()
writer.setMetadataRetrieve(omeMeta)
writer.setId(outFile)
type = reader.getPixelType()

# read and write main image
img = reader.openBytes(0)
writer.saveBytes(0, img)

# create ImageScaler for downsampling
scaler = SimpleImageScaler()
예제 #15
0
def computeWorldCorrection():
  x0, y0, z0 = 43324.0, 41836.0, 0.0
  x1, y1, z1 = 46780.0, 45532.0, 22950.0
  x2, y2, z2 = x0, y0, z1
  
  # A point in the first section that should be directly on top of the x0,y0,z0
  x3, y3, z3 = 48164, 23372, 0

  trans = Transform3D()
  trans.setTranslation(Vector3d(-x0, -y0, 0))

  rot = Transform3D()

  p0 = Vector3d(0, 0, z1)
  p1 = Vector3d(x1 - x0, y1 - y0, z1 - z0)
  pc = Vector3d()
  pc.cross(p1, p0)

  angle = Math.atan(Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)) / (z1 - z0))
  print angle * 180 / Math.PI

  rot.setRotation(AxisAngle4d(pc, angle))

  t = Transform3D()
  t.mul(rot)
  t.mul(trans)

  # Transform the third point
  p3 = Point3d(x3, y3, z3)
  t.transform(p3)
  print "A p3:", p3

  # test
  p0 = Point3d(x0, y0, z0)
  t.transform(p0)
  print "A: p0", p0

  p1 = Point3d(x1, y1, z1)
  t.transform(p1)
  print "A: p1", p1

  # Compute rotation of third point around Z axis
  rotZ = Transform3D()
  angleZ = Math.atan((p3.x - 0) / (p3.y - 0))
  print "angleZ", angleZ
  rotZ.setRotation(AxisAngle4d(Vector3d(0,0,1), angleZ))

  t.mul(rotZ, t)
  
  
  # test
  p0 = Point3d(x0, y0, z0)
  t.transform(p0)
  print p0

  p1 = Point3d(x1, y1, z1)
  t.transform(p1)
  print p1

  p3 = Point3d(x3, y3, z3)
  t.transform(p3)
  print p3

  return t
예제 #16
0
 def distxy(self, ox, oy):
     return Math.sqrt(Math.pow(self.x - ox, 2) + Math.pow(self.y - oy, 2))
예제 #17
0
파일: Proxy2D.py 프로젝트: WSCU/Reactive2d
def _distance(o1, o2):
    return Math.sqrt(Math.pow(o2.x - o1.x, 2) + Math.pow(o2.y - o1.y, 2))
예제 #18
0
def vector_y (percept, dist, scale, theta, p): 
    return Math.sin (deg2pi (180 + self.towards (percept.getX(), percept.getY()))) * theta / Math.pow ((dist / scale), p)
예제 #19
0
파일: Proxy2D.py 프로젝트: WSCU/Reactive2d
def _distance(o1, o2):
        return Math.sqrt(Math.pow(o2.x - o1.x,2) + Math.pow(o2.y - o1.y, 2))
예제 #20
0
def compute_heading ():
    if (mvt_mem.direction=="EAST"):
        x_modifier=2000
        y_modifier=0
    elif (mvt_mem.direction=="WEST"):
        x_modifier=-2000
        y_modifier=0
    elif (mvt_mem.direction=="SOUTH"):
        x_modifier=0
        y_modifier=+2000
    elif (mvt_mem.direction=="NORTH"):
        x_modifier=0
        y_modifier=-1000
        
    # on construit une liste de TOUS les objets  répulsifs
    repulsives = percepts.attackers.items () + \
                 percepts.explorers.items () + \
                 percepts.homes.items () + \
                 percepts.friends.items () + \
                 percepts.obstacles.items ()

    # valeurs magiques
    theta = 140
    scale = 25
    p = 2
    u = 30
    # composantes X et Y du vecteur direction final
    X = 0
    Y = 0
    if repulsives:
        for it, dist in repulsives:
            X = X + Math.cos (deg2pi (180 + self.towards (it.getX(), it.getY()))) * theta / Math.pow (dist/scale, p)
            Y = Y + Math.sin (deg2pi (180 + self.towards (it.getX(), it.getY()))) * theta / Math.pow (dist/scale, p)
        
    toterm ("AFTER REPULSION:"+str(X) +" "+ str(Y))
    X = X + Math.cos (deg2pi ( self.getHeading() ))*u
    Y = Y + Math.sin (deg2pi ( self.getHeading() ))*u
    toterm ("AFTER ATTRACTION:"+str(X) +" "+ str(Y))
    X+=x_modifier
    Y+=y_modifier 
    toterm ("NEW HEADING : "+str(self.towards (X, Y)))
    self.setHeading (self.towards (X, Y))     
예제 #21
0
 def test_pow(self):
     self.assertEqual(Math.pow(5, 3), 125)