Example #1
0
def findShift(image, reference, scale, angle):
    image = scipy.ndimage.zoom(image, scale)
    image = scipy.ndimage.rotate(image, angle)
    image = pad(image, reference.shape)
    cor = correlator.phase_correlate(reference, image, zero=False)
    results = peakfinder.findSubpixelPeak(cor, lpf=1.2)
    shift = correlator.wrap_coord(results['subpixel peak'], cor.shape)

    mrc_write(cor, 'finalcor.mrc')
    mrc_write(image, 'finalimage.mrc')
    mrc_write(reference, 'reference.mrc')

    return shift
def findShift(image, reference, scale, angle):
        image = scipy.ndimage.zoom(image, scale)
        image = scipy.ndimage.rotate(image, angle)
        image = pad(image, reference.shape)
        cor = correlator.phase_correlate(reference, image, zero=False)
        results = peakfinder.findSubpixelPeak(cor, lpf=1.2)
        shift = correlator.wrap_coord(results['subpixel peak'], cor.shape)

        mrc_write(cor, 'finalcor.mrc')
        mrc_write(image, 'finalimage.mrc')
        mrc_write(reference, 'reference.mrc')

        return shift
def findBestTransformValue(image, reference, start, end, increment, transfunc, *args, **kwargs):
        bestvalue = None
        bestshift = None
        bestsnr = 6.0
        bestnewimage = None
        for i, value in enumerate(numpy.arange(start, end, increment)):
                newimage = transfunc(image, value, *args, **kwargs)
                newimage = pad(newimage, reference.shape)
                cor = correlator.phase_correlate(reference, newimage, zero=False)
                mrc_write(cor, 'cor-%s-%03d.mrc' % (transfunc.__name__, i))
                results = peakfinder.findSubpixelPeak(cor, lpf=1.2)
                shift = correlator.wrap_coord(results['subpixel peak'], cor.shape)
                snr = results['snr']
                if debug:
                        print i, value, snr, shift
                if snr > bestsnr:
                        bestsnr = snr
                        bestvalue = value
                        bestshift = shift
                        bestnewimage = newimage
        return bestvalue, shift, cor, bestnewimage
Example #4
0
def findBestTransformValue(image, reference, start, end, increment, transfunc,
                           *args, **kwargs):
    bestvalue = None
    bestshift = None
    bestsnr = 6.0
    bestnewimage = None
    for i, value in enumerate(numpy.arange(start, end, increment)):
        newimage = transfunc(image, value, *args, **kwargs)
        newimage = pad(newimage, reference.shape)
        cor = correlator.phase_correlate(reference, newimage, zero=False)
        mrc_write(cor, 'cor-%s-%03d.mrc' % (transfunc.__name__, i))
        results = peakfinder.findSubpixelPeak(cor, lpf=1.2)
        shift = correlator.wrap_coord(results['subpixel peak'], cor.shape)
        snr = results['snr']
        if debug:
            print i, value, snr, shift
        if snr > bestsnr:
            bestsnr = snr
            bestvalue = value
            bestshift = shift
            bestnewimage = newimage
    return bestvalue, shift, cor, bestnewimage