BUG: Fixes segfault when image and labelmap have different sizes.

Change-Id: Iea5b1df3e14d6bb4feed7d8664910c7f4035e508

Check all input images.

Change-Id: If5430f9303d53fba175d8161c8673679757423cf