<jupyter_start><jupyter_text>First method<jupyter_code>start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the first method
ssim_anchorB_l=[]

ssim=0

for i in range(N):
    
    #anchorB given noisy particles transmitted with their weights
    anchor_B=[0,0]
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    anchor_B[0] = np.average(noisy_particles[:,0], weights=weights, axis=0).astype(int)
    anchor_B[1] = np.average(noisy_particles[:,1], weights=weights, axis=0).astype(int)
    
    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]

    #return droneB ROI
    BBb=return_bb_coordinates(anchor_B,height,width)
    roi_B=fov_B[BBb[0]:BBb[1],BBb[2]:BBb[3]]
    
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A1.jpg',draw_A)

        draw_B=draw_bb(fov_B.copy(),(BBb[2],BBb[0],width,height),anchor_B[0],anchor_B[1])
        cv2.imwrite(handover+'_ff_white_BB_B1.jpg',draw_B)
    
    #Compute the SSIM measure given two roi with the parameter gaussian_weights activate
    ssim=measure.compare_ssim(roi_A,roi_B, multichannel=True,\
                                          gaussian_weights=True)
    
    ssim_anchorB_l.append(ssim)
    
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_anchorB_l),stat.stdev(ssim_anchorB_l),\
max(ssim_anchorB_l),min(ssim_anchorB_l)<jupyter_output><empty_output><jupyter_text>Second Method<jupyter_code>start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the second method
ssim_noisy_particles_l=[]

ssim_max=0

for i in range(N):
    
    #Compute the noisy transmitted particles and use them to find and draw the combo
    #that gives the highest ssim 
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]
    
    #Compute the ssim with all noisy particles,retrieve the one that gives the maximal ssim
    anchor_ssim=max_min_ssim(noisy_particles,roi_A,fov_B,height,width)
    anchor_max,ssim_max=list(anchor_ssim[0]),anchor_ssim[1]
     
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A2.jpg',draw_A)

        BB_max=return_bb_coordinates(anchor_max,height,width)
        draw_max=draw_bb(fov_B.copy(),(BB_max[2],BB_max[0],width,height),anchor_max[0],\
                         anchor_max[1])
        cv2.imwrite(handover+'_ff_white_BB_B2.jpg',draw_max)

    ssim_noisy_particles_l.append(ssim_max)
    
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_noisy_particles_l),stat.stdev(ssim_noisy_particles_l),\
max(ssim_noisy_particles_l),min(ssim_noisy_particles_l)<jupyter_output><empty_output><jupyter_text>Third Method  New Particles = 2000<jupyter_code>n_particles_sampled=2000
start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the second method
ssim_new_particles_l=[]

ssim_max=0

for i in range(N):
    
    #Compute the noisy transmitted particles and use them to find and draw the combo
    #that gives the highest ssim 
    anchor_B=[0,0]
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    anchor_B[0] = np.average(noisy_particles[:,0], weights=weights, axis=0).astype(int)
    anchor_B[1] = np.average(noisy_particles[:,1], weights=weights, axis=0).astype(int)
    

    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]
    
    #Use new sampled particles around transmitted anchor and find and draw the combo that gives
    #the highest ssim
    particles_high=np.zeros((n_particles_sampled,2))
    particles_high[:,0]=anchor_B[0]+std_sampling*np.random.randn(n_particles_sampled)
    particles_high[:,1]=anchor_B[1]+std_sampling*np.random.randn(n_particles_sampled)

    anchor_ssim=max_min_ssim(particles_high,roi_A,fov_B,height,width)
    anchor_max,ssim_max=list(anchor_ssim[0]),anchor_ssim[1]
    
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A3_'+str(n_particles_sampled)+'.jpg',draw_A)

        BB_max=return_bb_coordinates(anchor_max,height,width)
        draw_max=draw_bb(fov_B.copy(),(BB_max[2],BB_max[0],width,height),anchor_max[0],\
                         anchor_max[1])
        cv2.imwrite(handover+'_ff_white_BB_B3_'+str(n_particles_sampled)+'.jpg',draw_max)
    
    ssim_new_particles_l.append(ssim_max)
        
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_new_particles_l),stat.stdev(ssim_new_particles_l),\
max(ssim_new_particles_l),min(ssim_new_particles_l)<jupyter_output><empty_output><jupyter_text>New Particles = 4000<jupyter_code>n_particles_sampled=4000
start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the second method
ssim_new_particles_l=[]

ssim_max=0

for i in range(N):
    
    #Compute the noisy transmitted particles and use them to find and draw the combo
    #that gives the highest ssim 
    anchor_B=[0,0]
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    anchor_B[0] = np.average(noisy_particles[:,0], weights=weights, axis=0).astype(int)
    anchor_B[1] = np.average(noisy_particles[:,1], weights=weights, axis=0).astype(int)
    

    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]
    
    #Use new sampled particles around transmitted anchor and find and draw the combo that gives
    #the highest ssim
    particles_high=np.zeros((n_particles_sampled,2))
    particles_high[:,0]=anchor_B[0]+std_sampling*np.random.randn(n_particles_sampled)
    particles_high[:,1]=anchor_B[1]+std_sampling*np.random.randn(n_particles_sampled)

    anchor_ssim=max_min_ssim(particles_high,roi_A,fov_B,height,width)
    anchor_max,ssim_max=list(anchor_ssim[0]),anchor_ssim[1]
    
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A3_'+str(n_particles_sampled)+'.jpg',draw_A)

        BB_max=return_bb_coordinates(anchor_max,height,width)
        draw_max=draw_bb(fov_B.copy(),(BB_max[2],BB_max[0],width,height),anchor_max[0],\
                         anchor_max[1])
        cv2.imwrite(handover+'_ff_white_BB_B3_'+str(n_particles_sampled)+'.jpg',draw_max)
    
    ssim_new_particles_l.append(ssim_max)
        
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_new_particles_l),stat.stdev(ssim_new_particles_l),\
max(ssim_new_particles_l),min(ssim_new_particles_l)<jupyter_output><empty_output><jupyter_text>New Particles = 6000<jupyter_code>n_particles_sampled=6000
start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the second method
ssim_new_particles_l=[]

ssim_max=0

for i in range(N):
    
    #Compute the noisy transmitted particles and use them to find and draw the combo
    #that gives the highest ssim 
    anchor_B=[0,0]
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    anchor_B[0] = np.average(noisy_particles[:,0], weights=weights, axis=0).astype(int)
    anchor_B[1] = np.average(noisy_particles[:,1], weights=weights, axis=0).astype(int)
    

    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]
    
    #Use new sampled particles around transmitted anchor and find and draw the combo that gives
    #the highest ssim
    particles_high=np.zeros((n_particles_sampled,2))
    particles_high[:,0]=anchor_B[0]+std_sampling*np.random.randn(n_particles_sampled)
    particles_high[:,1]=anchor_B[1]+std_sampling*np.random.randn(n_particles_sampled)

    anchor_ssim=max_min_ssim(particles_high,roi_A,fov_B,height,width)
    anchor_max,ssim_max=list(anchor_ssim[0]),anchor_ssim[1]
    
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A3_'+str(n_particles_sampled)+'.jpg',draw_A)

        BB_max=return_bb_coordinates(anchor_max,height,width)
        draw_max=draw_bb(fov_B.copy(),(BB_max[2],BB_max[0],width,height),anchor_max[0],\
                         anchor_max[1])
        cv2.imwrite(handover+'_ff_white_BB_B3_'+str(n_particles_sampled)+'.jpg',draw_max)
    
    ssim_new_particles_l.append(ssim_max)
        
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_new_particles_l),stat.stdev(ssim_new_particles_l),\
max(ssim_new_particles_l),min(ssim_new_particles_l)<jupyter_output><empty_output><jupyter_text>New Particles = 8000<jupyter_code>n_particles_sampled=8000
start_time = time.time()
#anchorA transmitted
anchor_A=list(est)

#List containnig the ssims for the second method
ssim_new_particles_l=[]

ssim_max=0

for i in range(N):
    
    #Compute the noisy transmitted particles and use them to find and draw the combo
    #that gives the highest ssim 
    anchor_B=[0,0]
    noisy_particles=np.zeros((n_particles,2))
    noisy_particles[:,0]=tx0+particles[:, 0]+std_fov*np.random.randn(n_particles)
    noisy_particles[:,1]=ty0+particles[:, 1]+std_fov*np.random.randn(n_particles)

    anchor_B[0] = np.average(noisy_particles[:,0], weights=weights, axis=0).astype(int)
    anchor_B[1] = np.average(noisy_particles[:,1], weights=weights, axis=0).astype(int)
    

    #return droneA ROI
    BBa=return_bb_coordinates(anchor_A,height,width)
    roi_A=fov_A[BBa[0]:BBa[1],BBa[2]:BBa[3]]
    
    #Use new sampled particles around transmitted anchor and find and draw the combo that gives
    #the highest ssim
    particles_high=np.zeros((n_particles_sampled,2))
    particles_high[:,0]=anchor_B[0]+std_sampling*np.random.randn(n_particles_sampled)
    particles_high[:,1]=anchor_B[1]+std_sampling*np.random.randn(n_particles_sampled)

    anchor_ssim=max_min_ssim(particles_high,roi_A,fov_B,height,width)
    anchor_max,ssim_max=list(anchor_ssim[0]),anchor_ssim[1]
    
    #Draw droneA and droneB ROI and FOV for one iteration
    if i==1:
        draw_A=draw_bb(fov_A.copy(),(BBa[2],BBa[0],width,height),anchor_A[0],anchor_A[1])
        cv2.imwrite(handover+'_ff_white_BB_A3_'+str(n_particles_sampled)+'.jpg',draw_A)

        BB_max=return_bb_coordinates(anchor_max,height,width)
        draw_max=draw_bb(fov_B.copy(),(BB_max[2],BB_max[0],width,height),anchor_max[0],\
                         anchor_max[1])
        cv2.imwrite(handover+'_ff_white_BB_B3_'+str(n_particles_sampled)+'.jpg',draw_max)
    
    ssim_new_particles_l.append(ssim_max)
        
prog_duration= time.time() - start_time
prog_duration
prog_duration/N
prog_duration/60
prog_duration/(60*N)
stat.mean(ssim_new_particles_l),stat.stdev(ssim_new_particles_l),\
max(ssim_new_particles_l),min(ssim_new_particles_l)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12809784357901513, 'fraction_numerical': 0.02252977148374638, 'mean_word_length': 5.4667013527575445, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '296508', 'license': 'MIT', 'n_tokens_mistral': 5086, 'n_tokens_neox': 4942, 'n_words': 627, 'path': 'data_handover_simulations.ipynb', 'repo_name': 'juliana2535/RM-codes', 'size': '12428'}