コード例 #1
0
ファイル: holo.py プロジェクト: wesleybowman/honours
def myHolo():
    ''' my holographic setup, which I think works since we use plane waves '''

    optics = hp.core.Optics(wavelen=635e-9, index=1.33, polarization=[1.0, 0.0])

    obj = hp.load('fibre1.png', spacing=7.6e-6, optics=optics)
    ref = hp.load('refFibre1.png', spacing=7.6e-6, optics=optics)

    holo = obj - ref

    rec = hp.propagate(holo, np.linspace(2.5e-2, 7.5e-2, 200))

    return rec
コード例 #2
0
ファイル: holo.py プロジェクト: wesleybowman/honours
def jericho():
    ''' using Dr. Jericho's setup and images, currently doesn't work.
        I think this is because Jericho using a spherical wave. '''

    optics = hp.core.Optics(wavelen=405e-9, index=1.33, polarization=[1.0, 0.0])

    obj = hp.load('jerichoObject.bmp', spacing=6e-6, optics=optics)
    ref = hp.load('jerichoRef.bmp', spacing=6e-6, optics=optics)

    holo=obj-ref

    #rec = hp.propagate(holo, np.linspace(200e-6, 300e-6, 10))
    rec = hp.propagate(holo, np.linspace(12.5e-3, 13e-3, 20))

    return rec
コード例 #3
0
ファイル: holo.py プロジェクト: wesleybowman/honours
def myHolo():

    optics = hp.core.Optics(wavelen=.632, index=1.33, polarization=[1.0, 0.0])

    #magnification = 40
    #Spacing = 6.8 / magnification
    Spacing = 0.1

    obj = hp.load('cgh.png', spacing=Spacing, optics=optics)
    #ref = hp.load('image0146.tif', spacing=Spacing, optics=optics)

    #holo = obj - ref
    holo = obj

    hp.show(holo)
    plt.show()

    rec = hp.propagate(holo, np.linspace(100, 150, 50))

    return rec
コード例 #4
0
ファイル: holotesting.py プロジェクト: wesleybowman/honours
def myHolo():
    ''' my holographic setup, which I think works since we use plane waves '''

    optics = hp.core.Optics(wavelen=635e-9, index=1.33, polarization=[1.0, 0.0])

    #obj = hp.load('tryit.png', spacing=7.6e-6, optics=optics)
    #ref = hp.load('ref.png', spacing=7.6e-6, optics=optics)

    obj = hp.load('fibreBright.png', spacing=7.6e-6, optics=optics)
    ref = hp.load('refBright.png', spacing=7.6e-6, optics=optics)

    #obj = hp.load('singleBright.png', spacing=7.6e-6, optics=optics)
    #ref = hp.load('singleRef.png', spacing=7.6e-6, optics=optics)

    holo = obj - ref

    ''' between 4 cm and 10 cm, should be about 5.5 cm '''
    #rec = hp.propagate(holo, np.linspace(4e-2, 10e-2, 200))
    rec = hp.propagate(holo, np.linspace(5e-2, 6e-2, 200))
    #rec = hp.propagate(holo, np.linspace(0.5e-2, 2e-2, 200))

    return rec
コード例 #5
0
from holopy.scattering import Spheres
from holopy.scattering import calc_holo, Sphere

imagepath = get_example_data_path('image01.jpg')
raw_holo = hp.load_image(
    imagepath,
    spacing=0.0851,
    medium_index=1.33,
    illum_wavelen=0.66,
)
bgpath = get_example_data_path(['bg01.jpg', 'bg02.jpg', 'bg03.jpg'])
bg = load_average(bgpath, refimg=raw_holo)
holo = bg_correct(raw_holo, bg)

z = np.linspace(0, 20, 200)
rec_vol = hp.propagate(holo, z)

x_arr = np.array([])
y_arr = np.array([])
for x in range(278, 292, 1):
    print(x)
    for y in range(248, 262, 1):

        phase_arr = np.array([])
        for i in range(0, len(z)):

            phase = np.angle(rec_vol[i][x][y])
            p = np.angle(np.e**(-1j * 2 * np.pi * z[i] / (0.66 / 1.33)))
            diff = phase - p
            if diff < -np.pi:
                diff = 0
コード例 #6
0
ファイル: basic_recon.py プロジェクト: ykiriscioglu/holopy
import numpy as np
import holopy as hp
from holopy.core.io import get_example_data_path, load_average
from holopy.core.process import bg_correct

imagepath = get_example_data_path('image01.jpg')
raw_holo = hp.load_image(
    imagepath,
    spacing=0.0851,
    medium_index=1.33,
    illum_wavelen=0.66,
)
bgpath = get_example_data_path(['bg01.jpg', 'bg02.jpg', 'bg03.jpg'])
bg = load_average(bgpath, refimg=raw_holo)
holo = bg_correct(raw_holo, bg)

zstack = np.linspace(0, 20, 11)
rec_vol = hp.propagate(holo, zstack)
hp.show(rec_vol)
コード例 #7
0
ファイル: 147holo.py プロジェクト: wesleybowman/honours
''' my holographic setup, which I think works since we use plane waves '''

optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

magnification = 40
Spacing = 6.8 / magnification

obj = hp.load('image0148.tif', spacing=Spacing, optics=optics)
ref = hp.load('image0146.tif', spacing=Spacing, optics=optics)

focus = hp.load('image0147.tif', spacing=Spacing, optics=optics)

holo = obj - ref

rec = hp.propagate(holo, np.linspace(1, 100, 50))

hp.show(focus)
plt.show()

hp.show(holo)
plt.show()

hp.show(rec)
plt.show()

''' 3D plotting - useful? '''
#from mayavi import mlab
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
コード例 #8
0
ファイル: blood.py プロジェクト: wesleybowman/honours
def loadHolo():
    optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

    magnification = 20
    Spacing = 6.8 / magnification

    obj = hp.load('P1000017.tiff', spacing=Spacing, optics=optics)
    ref = hp.load('P1000019.tiff', spacing=Spacing, optics=optics)

    holo = obj - ref

    return holo

holo = loadHolo()
#holo = holo[1100:1700,1200:1800]
rec = hp.propagate(holo, np.linspace(1500, 1600, 5))
#rec = hp.propagate(holo, 16000)

#hp.show(holo)
#plt.show()

hp.show(rec)
plt.show()

''' 3D plotting - useful? '''
#from mayavi import mlab
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
#mlab.outline()
#mlab.show()
コード例 #9
0
ファイル: holo.py プロジェクト: RobieH/honours
#optics = hp.core.Optics(wavelen=.405, index=1.33, polarization=[1.0, 0.0])

optics = hp.core.Optics(wavelen=.635, index=1.33, polarization=[1.0, 0.0])

# loading the images
#obj = hp.load('jerichoObject.bmp',spacing=6,optics=optics)
#ref = hp.load('jerichoRef.bmp',spacing=6,optics=optics)

obj = hp.load('fibre1.png',spacing=7.6,optics=optics)
ref = hp.load('refFibre1.png',spacing=7.6,optics=optics)

# contrast image
holo=obj-ref

# reconstruction, same image for all slices though
#rec = hp.propagate(holo, np.linspace(200,13e7,10))
rec = hp.propagate(holo, np.linspace(3.5e4,5.5e4,100))

# intensity so pyplot can plot it
recInt=abs(rec)*abs(rec)

hp.show(recInt)
plt.show()

''' 3D plotting - useful? '''
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
#mlab.outline()
#mlab.show()
コード例 #10
0
ファイル: testing.py プロジェクト: wesleybowman/honours
    magnification = 20
    Spacing = 6.8 / magnification

    obj = hp.load('P1000018.tiff', spacing=Spacing, optics=optics)
    ref = hp.load('P1000019.tiff', spacing=Spacing, optics=optics)

    holo = obj - ref

    return holo

holo = loadHolo()

#hp.show(holo)
#plt.show()

#holo = holo[1100:1700,1200:1800]
rec = hp.propagate(holo, np.linspace(1950, 2000, 5))
#rec = hp.propagate(holo, 16000)


hp.show(rec)
plt.show()

''' 3D plotting - useful? '''
#from mayavi import mlab
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
#mlab.outline()
#mlab.show()
コード例 #11
0
ファイル: 67.py プロジェクト: wesleybowman/honours
def loadHolo():
    optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

    magnification = 20
    Spacing = 6.8 / magnification

    obj = hp.load('P1000006.JPG', spacing=Spacing, optics=optics)
    ref = hp.load('P1000007.JPG', spacing=Spacing, optics=optics)

    holo = obj - ref

    return holo

holo = loadHolo()
#rec = hp.propagate(holo[1000:,1000:], np.linspace(15750, 16500, 10))
rec = hp.propagate(holo, 16000)

#hp.show(holo)
#plt.show()

hp.show(rec)
plt.show()

''' 3D plotting - useful? '''
#from mayavi import mlab
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
#mlab.outline()
#mlab.show()
コード例 #12
0
    spacing=0.0851,
    medium_index=1.33,
    illum_wavelen=0.66,
)
bgpath = get_example_data_path(['bg01.jpg', 'bg02.jpg', 'bg03.jpg'])
bg = load_average(bgpath, refimg=raw_holo)
holo = bg_correct(raw_holo, bg)

z = [17.5, 20, 27]
x = np.linspace(1, 512, 1000)

p1 = np.angle(np.e**(-1j * 2 * np.pi * z[0] / (0.66 / 1.33)))
p2 = np.angle(np.e**(-1j * 2 * np.pi * z[1] / (0.66 / 1.33)))
p3 = np.angle(np.e**(-1j * 2 * np.pi * z[2] / (0.66 / 1.33)))

rec_vol1 = hp.propagate(holo, z[0])
rec_vol2 = hp.propagate(holo, z[1])
rec_vol3 = hp.propagate(holo, z[2])

amp1 = np.abs(rec_vol1[:, 253, :])
amp2 = np.abs(rec_vol2[:, 253, :])
amp3 = np.abs(rec_vol3[:, 253, :])

phase1 = np.angle(rec_vol1[:, 253, :])
phase2 = np.angle(rec_vol2[:, 253, :])
phase3 = np.angle(rec_vol3[:, 253, :])

plt.figure(1)
plt.plot(amp1, label=z[0])
plt.plot(amp2, label=z[1])
plt.plot(amp3, label=z[2])
コード例 #13
0
ファイル: MultiHolo.py プロジェクト: wesleybowman/honours
optics = hp.core.Optics(wavelen=635e-9, index=1.33, polarization=[1.0, 0.0])

obj = hp.load('fibre1.png', spacing=7.6e-6, optics=optics)
ref = hp.load('refFibre1.png', spacing=7.6e-6, optics=optics)

holo = obj - ref
n,m = holo.shape

distance = np.linspace(2.5e-2, 7.5e-2, 200)
d=distance.shape

rowsX = [comm.rank + comm.size * aa for aa in range(int(n/comm.size)+1) if comm.rank + comm.size*aa < d]
reconstruction = np.empty((n,m))

comm.Barrier()

for z in rowsX:
    print(distance[z])
    rec = hp.propagate(holo, distance[z])
    reconstruction = np.dstack((reconstruction,rec))

comm.Barrier()

recInt = abs(reconstruction) * abs(reconstruction)

hp.show(recInt)
plt.show()



コード例 #14
0
ファイル: 155holo.py プロジェクト: wesleybowman/honours
import numpy as np
import matplotlib.pyplot as plt

''' my holographic setup, which I think works since we use plane waves '''

optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

magnification = 60
Spacing = 6.8 / magnification

obj = hp.load('image0100.tif', spacing=Spacing, optics=optics)
ref = hp.load('../image0156.tif', spacing=Spacing, optics=optics)

holo = obj - ref

rec = hp.propagate(holo, np.linspace(300, 400, 20))

#hp.show(holo)
#plt.show()

hp.show(rec)
plt.show()

recInt = abs(rec) * abs(rec)

from mayavi import mlab
mlab.contour3d(recInt)
#mlab.pipeline.volume(mlab.pipeline.scalar_field(recInt))
mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
mlab.outline()
mlab.show()
コード例 #15
0
ファイル: Reconstruction.py プロジェクト: gruffoc/DILHM
            lim = int(centro[0])
        if centro[1] + lim > Ly:
            lim = int(Ly - centro[1])
    else:
        if centro[1] - lim < 0:
            lim = int(centro[1])
        if centro[0] + lim > Lx:
            lim = int(Lx - centro[0])
    print(lim)

    #propagazione in z in una immagine ristretta da lim
    data_holo = raw_holo[:,
                         int(centro[0] - lim):int(centro[0] + lim),
                         int(centro[1] - lim):int(centro[1] + lim)]
    rec_vol = hp.propagate(data_holo,
                           z,
                           illum_wavelen=illum_wavelen,
                           medium_index=medium_index)

    #calcolo posizione di fuoco sia con ampiexxa del campo che con la fase
    modulo = propagation_module(z, rec_vol, lim)

    phase = np.angle(rec_vol)
    onda_riferimento = np.angle(np.e**((-1j * 2 * np.pi * z /
                                        (illum_wavelen / medium_index))))
    fase = propagation_phase(phase, onda_riferimento, z, lim)

    fase = np.nan_to_num(fase)
    max_d, min_d, max_zarray, min_zarray = maximum_minimum(fase, z)
    print("punto massimo (d):", max_d, ", punto minimo (d):", min_d)
    print("fuoco nell'array, punto di max:", max_zarray, ", punto di min:",
          min_zarray)
コード例 #16
0
ファイル: 154holo.py プロジェクト: wesleybowman/honours
    index = hype.argmax()
    return index

optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

magnification = 60
Spacing = 6.8 / magnification

obj = hp.load('image0100.tif', spacing=Spacing, optics=optics)
#obj = hp.load('image0001.tif', spacing=Spacing, optics=optics)
#obj = hp.load('image0020.tif', spacing=Spacing, optics=optics)
ref = hp.load('../image0156.tif', spacing=Spacing, optics=optics)

holo = obj - ref

rec = hp.propagate(holo, np.linspace(475, 505, 20))

#hp.show(holo)
#plt.show()

hp.show(rec)
plt.show()

a, b, c = rec.shape

hype = np.ones((a,b,c))


index = sobHypot(rec)
print(index)
index = TestsobHypot(rec)
コード例 #17
0
ファイル: 139holo.py プロジェクト: wesleybowman/honours
optics = hp.core.Optics(wavelen=.66, index=1.33, polarization=[1.0, 0.0])

magnification = 40
Spacing = 6.8 / magnification

obj = hp.load('image0139.tif', spacing=Spacing, optics=optics)
ref = hp.load('image0146.tif', spacing=Spacing, optics=optics)

holo = obj - ref

focus = hp.load('image0136.tif', spacing=Spacing, optics=optics)

hp.show(focus)
plt.show()

hp.show(holo)
plt.show()

rec = hp.propagate(holo, np.linspace(50, 200, 50))

hp.show(rec)
plt.show()

''' 3D plotting - useful? '''
#from mayavi import mlab
#mlab.contour3d(recInt)
##    mlab.pipeline.volume(mlab.pipeline.scalar_field(newImg))
#mlab.axes(x_axis_visibility=True,y_axis_visibility=True,z_axis_visibility=True)
#mlab.outline()
#mlab.show()
コード例 #18
0
ファイル: basic_recon.py プロジェクト: barkls/holopy
import numpy as np
import holopy as hp
from holopy.core.io import get_example_data_path, load_average
from holopy.core.process import bg_correct

imagepath = get_example_data_path('image01.jpg')
raw_holo = hp.load_image(imagepath, spacing = 0.0851, medium_index = 1.33, illum_wavelen = 0.66, )
bgpath = get_example_data_path(['bg01.jpg','bg02.jpg','bg03.jpg'])
bg = load_average(bgpath, refimg = raw_holo)
holo = bg_correct(raw_holo, bg)

zstack = np.linspace(0, 20, 11)
rec_vol = hp.propagate(holo, zstack)
hp.show(rec_vol)
コード例 #19
0
def calculate_hologram(window):
    print("calculate_hologram called.")
    try:
        back
        raw
    except:
        print(
            "calculate_hologram called with no data pls make sure background and hologram is available."
        )
        return
    global rec_vol

    if ui.TabSources.currentIndex() is 0:
        print("calculate_hologram called with point source!")

        #Calculate background correction and update metadata
        holo = hp.core.process.bg_correct(raw, back + 1, back)
        holo = hp.core.update_metadata(
            holo,
            medium_index=window.SpinBoxMedium.value(),
            illum_wavelen=window.SpinBoxWavelength.value() * 1e-9)

        #get beam center and set output shape
        beam_c = center_of_mass(back.values.squeeze())
        out_schema = hp.core.detector_grid(shape=ui.SpinBoxNPixOut.value(),
                                           spacing=ui.SpinBoxSpacing.value() *
                                           1e-6 /
                                           ui.SpinBoxMagnification.value())
        zstack = np.linspace(window.SpinBoxZMin.value() * 1e-6,
                             window.SpinBoxZMax.value() * 1e-6,
                             num=window.SpinBoxZStep.value(),
                             endpoint=True)

        #propagate through the raw hologram in zstack defined distances to reconstruct the wavefront at the object of interest
        rec_vol = hp.propagation.ps_propagate(
            holo, zstack,
            ui.SpinBoxDistance.value() * 1e-3, beam_c, out_schema)
        #process the reconstructions
    else:
        print("calculate_hologram called with collimated source!")
        holo = hp.core.process.bg_correct(raw, back)
        holo = hp.core.update_metadata(
            holo,
            medium_index=window.SpinBoxMedium_2.value(),
            illum_wavelen=window.SpinBoxWavelength_2.value() * 1e-9)

        zstack = np.linspace(window.SpinBoxZMin_2.value() * 1e-6,
                             window.SpinBoxZMax_2.value() * 1e-6,
                             num=window.SpinBoxZStep_2.value(),
                             endpoint=True)

        rec_vol = hp.propagate(holo, zstack)
        #process the reconstruct further
    scene = QtWidgets.QGraphicsScene(
    )  # scene: manipulate data to be shown in widget
    image = qim.array2qimage(
        np.abs(rec_vol.values[0]),
        True)  # get x-y values of the image and convert to QImage
    scene.addPixmap(
        QtGui.QPixmap(
            image).scaledToWidth(ui.GraphicsViewHologram.width() -
                                 2))  # QImage->QPixmap and add to the scene
    ui.GraphicsViewHologram.setScene(
        scene)  # set the scene to the background widget
    ui.GraphicsViewHologram.show()  # show the picture
    ui.HorizontalSliderHologram.setMaximum(ui.SpinBoxZStep.value() - 1)
    ui.HorizontalSliderHologram.setEnabled(True)
    print("Done calculation.")
コード例 #20
0
ファイル: h5test.py プロジェクト: wesleybowman/honours
    obj = hp.load('P1000018.tiff', spacing=Spacing, optics=optics)
    ref = hp.load('P1000019.tiff', spacing=Spacing, optics=optics)

    holo = obj - ref

    return holo

holo = loadHolo()

comm=MPI.COMM_WORLD

slices = np.arange(100,10100,100)
n=100
newSlices = [comm.rank + comm.size * aa for aa in range(int(n/comm.size)+1) if comm.rank + comm.size*aa < n]

comm.Barrier()


with tb.openFile('P1819.hdf','w') as f:
    matrix = f.createCArray(f.root, 'complexHologram',tb.ComplexAtom(itemsize=8), shape=(4016,3016,100))

    #count = 0
    for i in newSlices:

        print(i, slices[i])
        rec = hp.propagate(holo, slices[i])
        matrix[..., i] = rec
        #matrix[..., count] = rec
        #count += 1