示例#1
0
文件: v1filter.py 项目: yileidon/sims
 def V1Complex(vi):
     """
     it computes Angle-only, max-pooled version of V1Simple inputs.
     """
     vfilter.MaxPool(image.Point(2, 2), image.Point(2, 2), vi.V1sKwtaTsr,
                     vi.V1sPoolTsr)
     vfilter.MaxReduceFilterY(vi.V1sKwtaTsr, vi.V1sAngOnlyTsr)
     vfilter.MaxPool(image.Point(2, 2), image.Point(2, 2), vi.V1sAngOnlyTsr,
                     vi.V1sAngPoolTsr)
     v1complex.LenSum4(vi.V1sAngPoolTsr, vi.V1cLenSumTsr)
     v1complex.EndStop4(vi.V1sAngPoolTsr, vi.V1cLenSumTsr, vi.V1cEndStopTsr)
示例#2
0
 def Defaults(vi):
     vi.ClipToFit = True
     vi.DoG.Defaults()
     sz = 16
     spc = 2
     vi.DoG.SetSize(sz, spc)
     # note: first arg is border -- we are relying on Geom
     # to set border to .5 * filter size
     # any further border sizes on same image need to add Geom.FiltRt!
     vi.Geom.Set(image.Point(0, 0), image.Point(spc, spc),
                 image.Point(sz, sz))
     vi.ImgSize = image.Point(24, 24)
     vi.Geom.SetSize(vi.ImgSize.Add(vi.Geom.Border.Mul(2)))
     vi.DoG.ToTensor(vi.DoGTsr)
     # vi.ImgTsr.SetMetaData("image", "+")
     vi.ImgTsr.SetMetaData("grid-fill", "1")
示例#3
0
 def __init__(self):
     super(Vis, self).__init__()
     self.ClipToFit = True
     self.SetTags(
         "ClipToFit",
         'desc:"if true, and input image is larger than target image size, central region is clipped out as the input -- otherwise image is sized to target size"'
     )
     self.DoG = dog.Filter()
     self.SetTags("DoG", 'desc:"LGN DoG filter parameters"')
     self.Geom = vfilter.Geom()
     self.SetTags(
         "Geom",
         'inactive:"+" view:"inline" desc:"geometry of input, output"')
     self.ImgSize = image.Point()
     self.SetTags(
         "ImgSize",
         'desc:"target image size to use -- images will be rescaled to this size"'
     )
     self.DoGTsr = etensor.Float32()
     self.SetTags("DoGTsr", 'view:"no-inline" desc:"DoG filter tensor"')
     self.Img = image.Image()
     self.SetTags("Img", 'view:"-" desc:"current input image"')
     self.ImgTsr = etensor.Float32()
     self.SetTags("ImgTsr", 'view:"no-inline" desc:"input image as tensor"')
     self.OutTsr = etensor.Float32()
     self.SetTags("OutTsr",
                  'view:"no-inline" desc:"DoG filter output tensor"')
示例#4
0
文件: v1filter.py 项目: yileidon/sims
 def Defaults(vi):
     vi.V1sGabor.Defaults()
     sz = 6  # V1mF16 typically = 12, no border, spc = 4 -- using 1/2 that here
     spc = 2
     vi.V1sGabor.SetSize(sz, spc)
     # note: first arg is border -- we are relying on Geom
     # to set border to .5 * filter size
     # any further border sizes on same image need to add Geom.FiltRt!
     vi.V1sGeom.Set(image.Point(0, 0), image.Point(spc, spc),
                    image.Point(sz, sz))
     vi.V1sNeighInhib.Defaults()
     vi.V1sKWTA.Defaults()
     vi.ImgSize = image.Point(40, 40)
     vi.V1sGabor.ToTensor(vi.V1sGaborTsr)
     # vi.ImgTsr.SetMetaData("image", "+")
     vi.ImgTsr.SetMetaData("grid-fill", "1")
示例#5
0
    def FilterImg(ev):
        """
        FilterImg filters the image using new random xforms
        """
        ev.XFormRand.Gen(ev.XForm)
        oimg = ev.Images[ev.ImageIdx.Cur]

        insz = ev.Vis.Geom.In.Mul(2)
        ibd = oimg.Bounds()
        isz = ibd.Size()
        irng = isz.Sub(insz)
        st = image.Point()
        st.X = rand.Intn(irng.X)
        st.Y = rand.Intn(irng.Y)
        ed = st.Add(insz)
        simg = oimg.SubImage(image.Rectangle(Min=st, Max=ed))
        img = ev.XForm.Image(simg)
        ev.Vis.Filter(img)
示例#6
0
文件: leds.py 项目: ccnlab/leabrax
 def __init__(self):
     super(LEDraw, self).__init__()
     self.Width = float(4)
     self.SetTags(
         "Width",
         'def:"4" desc:"line width of LEDraw as percent of display size"')
     self.Size = float(0.6)
     self.SetTags(
         "Size",
         'def:"0.6" desc:"size of overall LED as proportion of overall image size"'
     )
     self.LineColor = "white"
     self.SetTags("LineColor", 'desc:"color name for drawing lines"')
     self.BgColor = "black"
     self.SetTags("BgColor", 'desc:"color name for background"')
     self.ImgSize = image.Point()
     self.SetTags("ImgSize", 'desc:"size of image to render"')
     self.Image = image.RGBA()
     self.SetTags("Image", 'view:"-" desc:"rendered image"')
     self.Paint = girl.Paint()
     self.SetTags("Paint", 'view:"+" desc:"painter object"')
     self.Render = girl.State()
     self.SetTags("Render", 'view:"-" desc:"rendering state"')
示例#7
0
文件: leds.py 项目: ccnlab/leabrax
 def Defaults(ld):
     ld.ImgSize = image.Point(120, 120)
     ld.Width = 4
     ld.Size = 0.6
     ld.LineColor = "white"
     ld.BgColor = "black"
示例#8
0
文件: v1filter.py 项目: yileidon/sims
 def __init__(self):
     super(Vis, self).__init__()
     self.V1sGabor = gabor.Filter()
     self.SetTags("V1sGabor", 'desc:"V1 simple gabor filter parameters"')
     self.V1sGeom = vfilter.Geom()
     self.SetTags(
         "V1sGeom",
         'inactive:"+" view:"inline" desc:"geometry of input, output for V1 simple-cell processing"'
     )
     self.V1sNeighInhib = kwta.NeighInhib()
     self.SetTags(
         "V1sNeighInhib",
         'desc:"neighborhood inhibition for V1s -- each unit gets inhibition from same feature in nearest orthogonal neighbors -- reduces redundancy of feature code"'
     )
     self.V1sKWTA = kwta.KWTA()
     self.SetTags("V1sKWTA", 'desc:"kwta parameters for V1s"')
     self.ImgSize = image.Point()
     self.SetTags(
         "ImgSize",
         'desc:"target image size to use -- images will be rescaled to this size"'
     )
     self.V1sGaborTsr = etensor.Float32()
     self.SetTags("V1sGaborTsr",
                  'view:"no-inline" desc:"V1 simple gabor filter tensor"')
     self.ImgTsr = etensor.Float32()
     self.SetTags("ImgTsr", 'view:"no-inline" desc:"input image as tensor"')
     self.Img = image.Image()
     self.SetTags("Img", 'view:"-" desc:"current input image"')
     self.V1sTsr = etensor.Float32()
     self.SetTags(
         "V1sTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output tensor"')
     self.V1sExtGiTsr = etensor.Float32()
     self.SetTags(
         "V1sExtGiTsr",
         'view:"no-inline" desc:"V1 simple extra Gi from neighbor inhibition tensor"'
     )
     self.V1sKwtaTsr = etensor.Float32()
     self.SetTags(
         "V1sKwtaTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, kwta output tensor"'
     )
     self.V1sPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, max-pooled 2x2 of V1sKwta tensor"'
     )
     self.V1sUnPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sUnPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, un-max-pooled 2x2 of V1sPool tensor"'
     )
     self.V1sAngOnlyTsr = etensor.Float32()
     self.SetTags(
         "V1sAngOnlyTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, angle-only features tensor"'
     )
     self.V1sAngPoolTsr = etensor.Float32()
     self.SetTags(
         "V1sAngPoolTsr",
         'view:"no-inline" desc:"V1 simple gabor filter output, max-pooled 2x2 of AngOnly tensor"'
     )
     self.V1cLenSumTsr = etensor.Float32()
     self.SetTags(
         "V1cLenSumTsr",
         'view:"no-inline" desc:"V1 complex length sum filter output tensor"'
     )
     self.V1cEndStopTsr = etensor.Float32()
     self.SetTags(
         "V1cEndStopTsr",
         'view:"no-inline" desc:"V1 complex end stop filter output tensor"')
     self.V1AllTsr = etensor.Float32()
     self.SetTags(
         "V1AllTsr",
         'view:"no-inline" desc:"Combined V1 output tensor with V1s simple as first two rows, then length sum, then end stops = 5 rows total"'
     )
     self.V1sInhibs = fffb.Inhibs()
     self.SetTags("V1sInhibs",
                  'view:"no-inline" desc:"inhibition values for V1s KWTA"')