def test_meshgrid(): nx, ny = (3, 2) x2 = numpy.linspace(0, 1, nx) y2 = numpy.linspace(0, 1, ny) x1 = afnumpy.array(x2) y1 = afnumpy.array(y2) iassert(afnumpy.meshgrid(x1, y1), numpy.meshgrid(x2, y2))
#data_fourier = np.zeros((1024,1024)).astype(np.complex64) # True image true_image = fft.fftshift(fft.ifftn(data_fourier)) #import arrayfire #print arrayfire.backend.name #print type(true_image) #print true_image.dtype #print intensities.dtype #print data_fourier.dtype # Initial image image = (1j + np.random.random(intensities.shape)).astype(np.complex64) # Define support yy,xx = np.meshgrid(np.arange(image.shape[0]), np.arange(image.shape[1])) rr = np.sqrt((xx-image.shape[1]/2)**2 + (yy-image.shape[0]/2)**2) support = rr < 24 #support = np.abs(true_image)>1 # Define Nr. of iterations nr_iterations = 500 # Define data constraint def data_constraint(fourier, intensities): return (fourier / np.abs(fourier)) * np.sqrt(intensities) # Define support constraint def support_constraint(img, support): img = img.flatten() img[support == 0] = 0