1. An image processing apparatus which changes a dynamic range of an image, comprising: histogram generation means for generating a differential histogram of the image over pixel value intervals; LUT generation means for automatically generating an LUT used for changing the dynamic range of the image on the basis of a histogram value in each pixel value interval of the histogram generated by said histogram generation means without requiring user intervention; and changing means for changing the dynamic range of the image on the basis of the LUT generated by said LUT generation means, wherein, in compressing the dynamic range of the image, said LUT generation means, iteratively, makes the variation in output pixel values small in each pixel value interval where the histogram values in the pixel value interval are small, shifts the output pixel values in other pixel value intervals to maintain pixel gradients in these other pixel value intervals, and redefines the pixel value intervals, until an output dynamic range of the image equals a desired dynamic range, and wherein, in expanding the dynamic range of the image, said LUT generation means, iteratively, makes the variation in output pixel values large in each pixel value interval where the histogram values in the pixel value interval are large, shifts the output pixel values in other pixel value intervals to maintain pixel gradients in these other pixel value intervals, and redefines the pixel value intervals, until an output dynamic range of the image equals a desired dynamic range.