Keeping images and captions together is crazy-making in epubs. I would *not* recommend rasterizing the image and caption together; almost all the ebook resellers caution you against that (and could make them reject your book) because the rasterized caption text is not searchable or selectable, and they get a lot of user complaints about it.
For the iPad, try enclosing your picture and caption in a div, and assign a “nobreak” style to that:
In the HTML:
<div class=”nobreak”>
<img src=”/images/San_Fran%2C_1822_fmt.jpeg” alt=”San_Fran1822.jpg”/>
alt=”San_Fran1822.jpg”>
<p class=”caption”>View of Presidio of San Francisco circa 1817 by Louis Choris</p>
</div>
In the CSS:
.nobreak {
page-break-inside: avoid;
}
Be careful because InDesign will add a bunch of divs to anything that's anchored. So test, and if necessary, prune unnecessary <div> </div> pairs.
AFAIK there's no way to set a “keep together” for Kindle devices. All you can do is set a page break before to force something to the top of a page.
AM