Example #1
0
def getQimage(dims, cc, color=(1.,1.,0.), factor = 4):
    print(dims)
    img = coords.coords2Image(dims, cc, factor, True)
    colorimg = np.zeros((img.shape[0],img.shape[1],4),dtype=np.uint8)
    mx = np.max(img)
    colorimg[:,:,0] = color[2]*img*(255./mx) # blue = LSB
    colorimg[:,:,1] = color[1]*img*(255./mx) # green
    colorimg[:,:,2] = color[0]*img*(255./mx) # red

    return colorimg
Example #2
0
def loadImage(filename, color=(1.,1.,0.), factor=4):
	print "reading file %s" % filename
	
	dims, cc = coords.readfile(filename)
	img = coords.coords2Image(dims, cc, factor=factor)
	colorimg = np.zeros((img.shape[0],img.shape[1],4),dtype=np.uint8)
	mx = np.max(img)
	colorimg[:,:,0] = color[2]*img*(255./mx) # blue = LSB
	colorimg[:,:,1] = color[1]*img*(255./mx) # green
	colorimg[:,:,2] = color[0]*img*(255./mx) # red

	return colorimg, cc, dims
Example #3
0
	def doTransformationButton_clicked(self):
		self.heatmatrix = self.transformcontroller.calculateTransform([self.m_npimages[0].shape[0]/self.m_factor, self.m_npimages[0].shape[1]/self.m_factor])
		self.emit(QtCore.SIGNAL("hideBeads()"))
		for i in range(1,len(self.m_npimages)):						#Transforms the coordinates of the green according to the transformation
			points = self.m_coords[i]
			p_transformed = self.transformcontroller.doTransform(points[:,0:2], i)
			points[:,0:2] = p_transformed
			points = coords.cropROI(points, (0, self.m_dims[0][0]-1, 0, self.m_dims[0][1]-1))
			img = coords.coords2Image(self.m_dims[i], points, self.m_factor)
			
			colorimg = np.zeros((img.shape[0],img.shape[1],4),dtype=np.uint8)
			mx = np.max(img)
			colorimg[:,:,1] = 1*img*(255./mx) # green

			self.m_npimages[i] = colorimg 
		self.recalculateResult()
Example #4
0
def plt_overview(dimension, coords, roi):
	# roi rectangle
	mybox=np.array([[roi[0],roi[0], roi[1], roi[1], roi[0]],[roi[2],roi[3],roi[3],roi[2],roi[2]]])

	#construct image from coordinates
	zoom_factor = 8
	im = cr.coords2Image(dimension, coords, zoom_factor)

	#plot
	plt.figure()
	plt.title("Storm image: " + overviewfile)
	plt.imshow(im)
	plt.hot() #colormap

	# rescale roi rectangle and plot it into the image
	mybox=zoom_factor*mybox
	plt.plot(mybox[0,...], mybox[1,...], '0.3')
	plt.axis([0,dimension[0]*zoom_factor,0,dimension[1]*zoom_factor])
	plt.colorbar()
if __name__ == "__main__":
    import matplotlib.pyplot as plt
    import coords
    import scipy
    file1 = 'data/HeLa5_10000z_3_polyL_actinmEOS2-steve.txt'
    file1_landmarks = 'data/HeLa5_10000z_3_polyL_actinmEOS2-steve.txt_beads.txt'
    file2 = 'data/HeLa5_10000z_3_polyL_ER647.txt'
    file2_landmarks = 'data/HeLa5_10000z_3_polyL_ER647.txt_beads.txt'

    thrash, landmarks1 = coords.readfile(file1_landmarks)
    thrash, landmarks2 = coords.readfile(file2_landmarks)
    landmarks1 = landmarks1[:,:2]
    landmarks2 = landmarks2[:,:2]
    trafo = affineMatrix2DFromCorrespondingPoints(landmarks2, landmarks1)
    print("Transformation: \n", trafo)

    dims, cc1 = coords.readfile(file1)
    dims, cc2 = coords.readfile(file2)
    cc2_ones = np.hstack([cc2[:,:2], np.ones((len(cc2),1))]) # add column with ones for affine trafo
    cc2_transformed = np.dot(cc2_ones, trafo.T)[:,:2]
    cc2_transformed = np.hstack([cc2_transformed,cc2[:,2:]]) # add intensity information again

    im1 = coords.coords2Image(dims, cc1)
    im2 = coords.coords2Image(dims, cc2_transformed)

    im_color = np.dstack([im1/np.max(im1),im2/np.max(im2),np.zeros(im1.shape)])
    scipy.misc.imsave(file1+"_processed.png", im_color)
    plt.imshow(im_color)
    plt.plot(landmarks1[:,0]*8, landmarks1[:,1]*8, 'wo', alpha=0.4, scalex=False, scaley=False)
    plt.show()