예제 #1
0
def layer(c,file,gds_layer):
  try:
    img = readmagick.readimg(file)
  except:
    return
  img = img[:,:,0]
  height,width = img.shape
  y = 0
  while True:
    box = extract_box(img,y)
    if not box:
      break
    (x,y,x2,y2) = box
    c.add(gdspy.Rectangle(gds_layer, (x,height-y), (x2,height-y2)))
예제 #2
0
def layer(c, file, gds_layer):
    try:
        img = readmagick.readimg(file)
    except:
        return
    img = img[:, :, 0]
    height, width = img.shape
    y = 0
    while True:
        box = extract_box(img, y)
        if not box:
            break
        (x, y, x2, y2) = box
        c.add(gdspy.Rectangle(gds_layer, (x, height - y), (x2, height - y2)))
예제 #3
0
def layer(file,cif_name):
  global height
  try:
    img = readmagick.readimg(file)
  except:
    return
  print 'L '+cif_name+';'
  img = img[:,:,0]
  height,width = img.shape
  y = 0
  while True:
    box = extract_box(img,y)
    if not box:
      break
    (x,y,x2,y2) = box
    print ' B %d %d %d %d;' % (2*(x2-x),2*(y2-y),x+x2,2*height-(y+y2))
예제 #4
0
def layer(file, cif_name):
    global height
    try:
        img = readmagick.readimg(file)
    except:
        return
    print 'L ' + cif_name + ';'
    img = img[:, :, 0]
    height, width = img.shape
    y = 0
    while True:
        box = extract_box(img, y)
        if not box:
            break
        (x, y, x2, y2) = box
        print ' B %d %d %d %d;' % (2 * (x2 - x), 2 *
                                   (y2 - y), x + x2, 2 * height - (y + y2))
예제 #5
0
def produce_mosaics(prep_list, pwi_file, annotations, output_dir, temp_im_dir):
    num_preps = len(prep_list)
    dl_file = urllib.URLopener()
    for idx in range(0, num_preps):
        cur_url_list = pwi_file[idx]
        cur_annotations = annotations[idx]
        #backup_cur_url_list = back_pwi_file[idx]
        num_urls = len(cur_url_list)
        i = 0
        il = 1
        while il < len(cur_url_list) and il < num_ims_to_plot:
            try:
                dl_name = temp_im_dir + '/' + str(il - 1) + '.jpg'
                #try:
                #dl_file.retrieve(cur_url_list[il], dl_name)
                response = urllib.urlopen(cur_url_list[il])
                content = response.read()
                f = open(dl_name, 'w')
                f.write(content)
                f.close()
                #except Exception, e:
                #dl_file.retrieve(backup_cur_url_list[il], dl_name)
                im = readmagick.readimg(dl_name)
                ax = pylab.subplot(subplot_arrangement[0],
                                   subplot_arrangement[1],
                                   il,
                                   frameon=False,
                                   xticks=[],
                                   yticks=[])
                str_list = [x.encode('UTF8') for x in cur_annotations[il]]
                ax.set_title(' '.join(str_list), fontsize=4, y=1.08)
                pylab.imshow(im)
                print("Finished image #" + str(il))
            except Exception, g:
                print("Skipping image #" + str(il))
            il += 1
        pylab.savefig(output_dir + '/' + prep_list[idx] + '.jpg',
                      format='jpg',
                      dpi=1000)
        remove_files(temp_im_dir + '/*')
예제 #6
0
import numpy as np
import scipy
import pylab
import pymorph
import readmagick
from scipy import ndimage
from pylab import cm
import pit
dna = readmagick.readimg('dna.jpeg')

TESTING = False
if TESTING:

    def savejet(img, name):
        pass

    def writeimg(img, name):
        pass
else:

    def savejet(img, name):
        img = (img - img.min()) / float(img.ptp()) * 255
        img = img.astype(np.uint8)
        readmagick.writeimg((cm.jet(img)[:, :, :3] * 255).astype(np.uint8),
                            name)

    writeimg = readmagick.writeimg

dnaf = ndimage.gaussian_filter(dna, 8)
rmax = pymorph.regmax(dnaf)
pylab.imshow(pymorph.overlay(dna, rmax))
    for labIndex in range(1, labmax + 1):
        flatParticleList.append(eT[eT[:, 0] == labIndex])  # from Matthieu Brucher
    return unflattenParticles(flatParticleList)


#
# Modify your path to your images here. The script works with 16bits images
#
user = os.path.expanduser("~")
workdir = os.path.join(user, "Applications", "ImagesTest", "jp", "Jpp48", "13", "DAPI")
file = "1.tif"
complete_path = os.path.join(workdir, file)
#
#
if __name__ == "__main__":
    dapi = readmagick.readimg(complete_path)
    os.mkdir(os.path.join(workdir, "particules"))
    im1 = RemoveModalBackground(dapi)
    # 8bits dapi image
    d8 = gray12_to8(im1)
    # try a simple segmentation procedure
    print "segmenting..."
    # imlabel=GradBasedSegmentation(im1)
    imlabel, npart = nd.label(LowResSegmentation(dapi))
    print "showing..."
    # pylab.imshow(imlabel)
    # pylab.show()
    # Particles is a list of images
    Particles = extractParticles(im1, imlabel)
    li = 1
    ColNum = 10  # ten columns and len(Particles)/ColNum lines
#

pins = {}

f = open(sys.argv[1], "r")
for x in f.readlines():
    l = string.split(x)
    name, x, y = l[0], int(l[1]), int(l[2])
    pins[name] = (x, y)
f.close()

#
# read in the mask bitmaps and label them
#

metal, metal_n = ndimage.label(readmagick.readimg(sys.argv[2]))
diffusion, diffusion_n = ndimage.label(readmagick.readimg(sys.argv[3]))
contact, contact_n = ndimage.label(readmagick.readimg(sys.argv[4]))
gate, gate_n = ndimage.label(readmagick.readimg(sys.argv[5]))
implant, implant_n = ndimage.label(readmagick.readimg(sys.argv[6]))

print '# metal: %d objects' % metal_n
print '# diffusion: %d objects' % diffusion_n
print '# contact: %d objects' % contact_n
print '# gate: %d objects' % gate_n
print '# implant: %d objects' % implant_n

#
# emit "pin" objects that intersect metal or diffusion
#
예제 #9
0
import numpy as np
import scipy
import pylab
import pymorph
import readmagick
import pit
from scipy import ndimage
dna = readmagick.readimg('dna.jpeg')

TESTING = True
if TESTING:
    def savejet(img, name):
        pass
else:
    def savejet(img):
        readmagick.writeimg((cm.jet(dnaf)[:,:,:3]*255).astype(np.uint8), name)
    
pylab.imshow(dna)
pylab.show()
savejet(dna, 'dna-coloured.jpeg')

pylab.imshow(dna)
pylab.gray()
pylab.show()

print dna.shape
print dna.dtype
print dna.max()
print dna.min()

pylab.imshow(dna // 2)
예제 #10
0
#

pins = {}

f = open(sys.argv[1],"r")
for x in f.readlines():
  l = string.split(x)
  name,x,y = l[0],int(l[1]),int(l[2])
  pins[name] = (x,y)
f.close()

#
# read in the mask bitmaps and label them
#

metal,metal_n = ndimage.label(readmagick.readimg(sys.argv[2]))
diffusion,diffusion_n = ndimage.label(readmagick.readimg(sys.argv[3]))
contact,contact_n = ndimage.label(readmagick.readimg(sys.argv[4]))
gate,gate_n = ndimage.label(readmagick.readimg(sys.argv[5]))
implant,implant_n = ndimage.label(readmagick.readimg(sys.argv[6]))

print '# metal: %d objects' % metal_n
print '# diffusion: %d objects' % diffusion_n
print '# contact: %d objects' % contact_n
print '# gate: %d objects' % gate_n
print '# implant: %d objects' % implant_n

#
# emit "pin" objects that intersect metal or diffusion
#
예제 #11
0
def test_readimgfromblob():
    img0 = readmagick.readimg(_testimg)
    img1 = readmagick.readimgfromblob(file(_testimg).read())
    assert img0.shape == img1.shape
    assert np.all(img0 == img1)
예제 #12
0
def load_aabid(col,id):
    from readmagick import readimg
    id = ('../data/images/segmented-ashariff/%s/dna-%s.psd' % (col,id))
    I = readimg(id)
    B = (I[:,:,0] > I[:,:,1])
    return _process_B(B)
예제 #13
0
def __fakeimg():
    dna = readimg('tests/data/dnaimg.jp2')
    img = pyslic.Image()
    img.channeldata['dna'] = dna
    img.loaded = True
    return img
예제 #14
0
def test_thresholding():
    dna = readimg('tests/data/dnaimg.jp2')
    segmented = pyslic.segmentation.thresholding.threshold_segment(dna)
    assert dna.shape == segmented.shape
예제 #15
0
def write_readback(C,fname):
    C = C.copy()
    writeimg(C,fname)
    C2 = readimg(fname)
    return C, C2
예제 #16
0
import readmagick
import pymorph
import mahotas
dna = readmagick.readimg('dna-0.xcf[0]').max(2)
dna2 = readmagick.readimg('dna-1.xcf[0]').max(2)
borders = readmagick.readimg('dna-0.xcf[1]')
borders = borders[:,:,0] > borders[:,:,1]
for i in xrange(2): borders = mahotas.dilate(borders, np.ones((3,3)))
readmagick.writeimg(pymorph.overlay(dna, borders), 'dna.png')
readmagick.writeimg(pymorph.overlay(dna2, borders), 'dna2.png')

예제 #17
0
    #label of the last particle
    flatParticleList=[]#from Matthieu Brucher
    for labIndex in range(1,labmax+1):
        flatParticleList.append(eT[eT[:,0]==labIndex])#from Matthieu Brucher
    return unflattenParticles(flatParticleList)
#
#Modify your path to your images here. The script works with 16bits images
#
user=os.path.expanduser("~")
workdir=os.path.join(user,"Applications","ImagesTest","jp","Jpp48","2","DAPI")
file="1.tif"
complete_path=os.path.join(workdir,file)
#
#
if __name__ == "__main__":
    dapi=readmagick.readimg(complete_path)
    print "shape dapi",dapi.shape
    os.mkdir(os.path.join(workdir,"particules"))
    im1=RemoveModalBackground(dapi)
    #8bits dapi image
    d8=gray12_to8(im1)
    #try a simple segmentation procedure
    print "segmenting..."
    #imlabel=GradBasedSegmentation(im1)
    imlabel,npart=nd.label(LowResSegmentation(dapi))
    print "showing..."
    #pylab.imshow(imlabel)
    #pylab.show()
    #Particles is a list of images
    Particles=extractParticles(im1,imlabel)
    li=1