1. A three-dimensional labeling apparatus that performs labeling for a three-dimensional image, which is a set of three-dimensionally placed pixels, comprising: a three-dimensionally-shaped neighboring mask that covers a plane containing a target pixel and planes adjacent to the plane and enables refer to pixels in the vicinity of the target pixel; and a labeling device that scans the neighboring mask within the three-dimensional image and assigns a label number to the target pixel, based on the value or label number of the target pixel contained in the neighboring mask.