41 #include "hawki_saa.h"
53 int hawki_geom_refine_images_offsets
55 cpl_bivector * approx_offsets,
56 cpl_bivector * reference_objects,
61 cpl_bivector * refined_offsets,
64 cpl_bivector * offs_ref ;
67 double * correl_data ;
73 if (approx_offsets == NULL)
return -1;
74 if (refined_offsets == NULL)
return -1;
77 nimages = cpl_imagelist_get_size(in) ;
78 if (cpl_bivector_get_size(approx_offsets) != nimages)
80 cpl_msg_error(__func__,
"Invalid input objects sizes") ;
85 cpl_msg_info(__func__,
"Refine the offsets") ;
86 cpl_msg_indent_more() ;
87 if ((offs_ref = cpl_geom_img_offset_fine
88 (in, approx_offsets, reference_objects,
89 s_hx, s_hy, m_hx, m_hy, correl)) == NULL)
91 cpl_msg_error(cpl_func,
"Cannot refine the offsets");
92 cpl_vector_delete(correl) ;
97 offs_ref_x = cpl_bivector_get_x_data(offs_ref) ;
98 offs_ref_y = cpl_bivector_get_y_data(offs_ref) ;
99 correl_data = cpl_vector_get_data(correl) ;
100 cpl_msg_info(cpl_func,
"Refined relative offsets [correlation factor]") ;
102 for (i=0 ; i<nimages ; i++)
104 cpl_msg_info(cpl_func,
"#%02d: %8.2f %8.2f [%12.2f]",
105 i+1, offs_ref_x[i], offs_ref_y[i], correl_data[i]) ;
106 if (correl_data[i] > -0.5) ngood++ ;
110 cpl_msg_error(__func__,
"No frame correctly correlated") ;
111 cpl_bivector_delete(offs_ref) ;
112 cpl_vector_delete(correl) ;
115 cpl_msg_indent_less();
118 cpl_vector_copy(cpl_bivector_get_x(refined_offsets),
119 cpl_bivector_get_x(offs_ref));
120 cpl_vector_copy(cpl_bivector_get_y(refined_offsets),
121 cpl_bivector_get_y(offs_ref));
124 cpl_bivector_delete(offs_ref);
125 cpl_msg_indent_less() ;