I basically did what Ghaul suggested , but replaced it imline()with a manual search for the underlying pixels. The advantage is that the figure is not shown, which brings some speed advantages (~ 0.5 s in my tests);
dist_euc = norm(p1 - p2);
n_pix = round(dist_euc*2);
step = (p1 - p2)/n_pix;
pix_coords = zeros(n_pix, 2);
for cp = 0:n_pix
pix_coords(cp+1, :) = round(p2 + cp*step);
end
pix_inds = sub2ind(size(im), pix_coords(:,2), pix_coords(:,1));
pix_inds = unique(pix_inds);
im(pix_inds) = interpft(prof, length(pix_inds));
source
share