Exemplo n.º 1
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')

Exemplo n.º 2
0
def write_readback(C,fname):
    C = C.copy()
    writeimg(C,fname)
    C2 = readimg(fname)
    return C, C2
Exemplo n.º 3
0
 def test_one(C,fname,correct):
     writeimg(C,fname)    
     C,C2 = write_readback(C,fname)
     if correct: C2 //= 257
     assert C.shape == C2.shape
     assert numpy.all(C == C2)
    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
    il = 0
    iw = 0
    for i in range(0, len(Particles)):
        # first convert and save particle as 8bits png image
        file = "part" + str(i) + ".png"
        saveim = gray12_to8(Particles[i])
        pathtoparticles = os.path.join(workdir, "particules", file)
        savedfile = saveim.astype(np.uint8)
        readmagick.writeimg(savedfile, pathtoparticles)
        print "saving:" + file
        # loading a 8bits png
        # (next thing to do:building a mosaic directly from Particles list)
        #
        # print pathtoparticles
        # impng=readmagick.readimg(pathtoparticles)
        # col=i%ColNum+1
        # print "im shape:",impng.shape," i:",i," li:",li," col:",col
        # there should be len(Particles)+1 subplots
        # pylab.subplot(1,i+1,i+1)
        # pylab.imshow(impng)
        # if col == 1 :
        #    li=li+1
    # pylab.show()
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 def savejet(img):
     readmagick.writeimg((cm.jet(dnaf)[:,:,:3]*255).astype(np.uint8), name)
Exemplo n.º 7
0
 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
 il=0
 iw=0
 for i in range(0,len(Particles)):
     #first convert and save particle as 8bits png image
     file='part'+str(i)+'.png'
     saveim=gray12_to8(Particles[i])
     pathtoparticles=os.path.join(workdir,"particules",file)
     savedfile=saveim.astype(np.uint8)
     readmagick.writeimg(savedfile, pathtoparticles)
     print "saving:"+file
     #loading a 8bits png
     #(next thing to do:building a mosaic directly from Particles list)
     #
     #print pathtoparticles
     #impng=readmagick.readimg(pathtoparticles)
     #col=i%ColNum+1
     #print "im shape:",impng.shape," i:",i," li:",li," col:",col
     #there should be len(Particles)+1 subplots
     #pylab.subplot(1,i+1,i+1)
     #pylab.imshow(impng)
     #if col == 1 :
     #    li=li+1
 #pylab.show()
Exemplo n.º 8
0
 def savejet(img):
     readmagick.writeimg((cm.jet(dnaf)[:, :, :3] * 255).astype(np.uint8),
                         name)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
def write(img, name):
    transformed = (img - img.min()).astype(float)/img.ptp()
    transformed = (transformed * 255).astype(np.uint8)
    readmagick.writeimg(transformed, name)