python - Which kind of interpolation best for resizing image? - Stack Overflow
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
- Add NTK-Aware interpolation "by parts" correction by bloc97 · Pull Request #1 · jquesnelle/yarn · GitHubgithub.com
- Paper Shaders – Ultra-fast zero-dependency shadersshaders.paper.design
- Optimizing Cubature for Efficient Integration of Subspace Deformationscs.cornell.edu
- bspline - B-spline interpolation with Python - Stack Overflowstackoverflow.com
- ToTensor - Torchvision main documentationdocs.pytorch.org
- Topaz Gigapixel - Super-size & Upscale Image & Photo Resolutiontopazlabs.com
- Fast Quasi-Harmonic Weights for Geometric Data Interpolationpeople.csail.mit.edu
- Cubic Interpolation of Quaternionstheorangeduck.com
- Image to Mesh Gradientphotogradient.com
- Go smol or go home | Harm de Vriesharmdevries.com
- pytorch-image-models/timm/models/vision_transformer.py at main · huggingface/pytorch-image-models · GitHubgithub.com
- Image module - Pillow (PIL Fork) 12.3.0 documentationpillow.readthedocs.io