flâneur — a map of the web's best reading

python - Which kind of interpolation best for resizing image? - Stack Overflow

stackoverflow.com · 2,063 words · saved by 1 readers

I have a numpy array that I wish to resize using opencv. Its values range from 0 to 255. If I opt to use cv2.INTER_CUBIC, I may get values outside this range. This is undesirable, since the resized array is supposed to still represent an image. One solution is to clip the results to [0, 255]. Another is to use a different interpolation method. It is my understanding that using INTER_AREA is valid for down-sampling an image, but works similar to nearest neighbor for upsampling it, rendering it less than optimal for my purpose. Should I use INTER_CUBIC (and clip), INTER_AREA, or INTER_LINEAR? an example for values outside of range using INTER_CUBIC: Edit: As berak pointed out, converting the type to float (from int64) allows for values outside the original range. the cv2.resize() function does not work with the default 'int64' type. However, converting to 'uint8' will automatically saturate the values to [0..255]. Also, as pointed out by SaulloCastro, another related answer demonstrated

python - Which kind of interpolation best for resizing image? - Stack Overflow New: Stack Overflow For Agents. The next generation of knowledge exchange. Learn more Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives Stack Internal Knowledge at work Bring the best of human thought and AI automation together at your work. Explore Stack Internal Which kind of interpolation best for resizing image? Ask Question Asked 12 years ago Modified 1 year, 3 months ago Viewed 172k times 70 I have a numpy array t

Explore this link on the map →

saved by

related reading