To provide an image processing method and device capable of creating optimal mask image data for use in masking image data and to provide a program.
The image processing device is provided with a distribution data creating part 222 creating distribution data d1 that constitutes image data S11 and that shows a distribution of a plurality of pixel data showing pixel values within a predefined range r1; a specifying part 223 for specifying a threshold M based on the distribution data d11 created by the distribution data creating part 222 and a preset value Mth, or more specifically on a pattern d11 showing the features of the subject of masking in the distribution data d1; a binarizing part 224 that performs binarization based on the threshold specified by the specifying part 223 to generate the mask image data S22; and a subdividing part 225.