In order to obtain the number of pixels of the yellow line which you know it's real distance is 11.72 mm in the vertebral column image, you could try this
[cx,cy, rgbValues, xi,yi] = improfile(1000);
oimg = findobj(gca,'Type','image');
img = get(oimg, 'CData');
d_line = round(sqrt((xi(1)-xi(2))^2 + (yi(1)-yi(2))^2))
[cx,cy, rgbValues] = improfile(img, xi, yi, d_line);
rgbValues = squeeze(rgbValues);
d_pixels= sqrt( (xi(2)-xi(1)).^2 + (yi(2)-yi(1)).^2);
plot(xi, yi, 'r-');
For the first image you would finally know the distance in pixels and the real distance (mm) , being able to define the conversion factor: mm/px or px/mm, but only for elements in that specific image.
In order to compare between the pixel distances of each image to see if they match, you should get a scale factor of each image (haven't tried the code right now)
And for the second image the same,
Then you could scale one image to the other and finally compare the heights.