Imagej - an excellent tool :-) Yep, this sounds like a perfect use case for ImageJ, and I'm certain people have used it for exactly that before. There may already be a macro or plugin that does this. But the people who would know about that are unlikely to hang out here - post to the
ImageJ mailing list, and you're likely to get help much faster than here. (Having that said, I do hang out here and am happy to provide help with
Java development around ImageJ, but the mailing list would be a better first stop for this specific application.)