function res = h3d_find_hs_peak(s) glob = []; for f=1:6 face = squeeze(s.cube_hs(f,:,:)); [coords,val] = h3d_matrix_local_maxima(face); num = numel(val); m = [val/10000; f * ones(1,num); coords];; if f==1 glob = m; else glob = [glob m]; end end for a=1:size(glob,2) out(1,a) = glob(1,a); face = glob(2,a); i = glob(3,a); j = glob(4,a); [face, u, v] = h3d_coords_cell_to_avg_cube(face, i, j, s.cube_ncells); out(2:4,a) = h3d_coords_cube_to_s2(face, u, v); % fprintf('val %f at %d %d %d -> %f %f %f \n', v(1,a)) end [Y,I] = sort(out(1,:),'descend'); out = out(:,I); indexes = h3d_filter_results(out(2:4,:), 10); out = out(:,indexes); res =out;