def computeKatzLines(kSpace, anglesSorted, finiteAnglesSorted, K, centered = True, twoQuads = False): ''' compute finite lines coordinates given Katz criterion Returns a list or list of slice 2-tuples and corresponding list of angles and m values perp computes the perpendicular (s) lines as well ''' N, M = kSpace.shape lines = [] angles = [] mValues = [] for m, angle in zip(finiteAnglesSorted, anglesSorted): if isKatzCriterion(N, N, angles, K): print("Katz Criterion Met. Breaking") break m, inv = farey.toFinite(angle, N) u, v = radon.getSliceCoordinates2(m, kSpace, centered) lines.append((u,v)) mValues.append(m) angles.append(angle) #second quadrant if twoQuads: if m != 0 and m != N: #dont repeat these m = N-m u, v = radon.getSliceCoordinates2(m, kSpace, centered) lines.append((u,v)) mValues.append(m) p, q = farey.get_pq(angle) newAngle = farey.farey(-p,q) #not confirmed angles.append(newAngle) return lines, angles, mValues
def mojetteProjection(projection, N, angle, P, Q): ''' Convert a finite projection into a Mojette projection for given (p,q). Assumes you have correctly determined (p,q) for the m value of the finite projection. ''' # dyadic = True # if N % 2 == 1: # if odd, assume prime # dyadic = False p, q = farey.get_pq(angle) B = farey.projectionLength(angle, P, Q) #no. of bins m, inv = farey.toFinite(angle, N) translateOffset, perp = farey.finiteTranslateOffset(angle, N, P, Q) mojetteProj = np.zeros(B) angleSign = p * q '''if nt.is_coprime(q, N): inv = q else: #perp projection inv = p for translate, bin in enumerate(projection): translateMojette = int((inv*translate)%N) if angleSign >= 0 and perp: #Reverse for perp translateMojette = int(translateOffset) - translateMojette else: translateMojette += int(translateOffset) print "TR:", translate, "Tm:", translateMojette mojetteProj[translateMojette] += bin''' for translate, bin in enumerate(mojetteProj): if angleSign >= 0 and perp: #Reverse for perp translateMojette = int(translateOffset) - int(translate) else: translateMojette = int(translate) - int(translateOffset) if translateMojette < 0: translateFinite = (N - (inv * abs(translateMojette)) % N) % N else: translateFinite = (inv * translateMojette ) % N #has issues in C, may need checking mojetteProj[translate] += projection[translateFinite] # print "TR:", translateFinite, "TM:", translate return mojetteProj
def computeLines(kSpace, angles, centered = True, twoQuads = False): ''' compute finite lines coordinates Returns a list or list of slice 2-tuples and corresponding list of m values ''' p, s = kSpace.shape lines = [] mValues = [] for angle in angles: m, inv = farey.toFinite(angle, p) u, v = radon.getSliceCoordinates2(m, kSpace, centered, p) lines.append((u,v)) mValues.append(m) #second quadrant if twoQuads: if m != 0 and m != p: #dont repeat these m = p-m u, v = radon.getSliceCoordinates2(m, kSpace, centered, p) lines.append((u,v)) mValues.append(m) return lines, mValues