From e56d1eff13bf8b6863cd213db157b9544cb9e3a7 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Tue, 21 Jul 2015 18:46:24 +0000
Subject: [PATCH] Switch to fast resize

---
 src/image.c |   25 ++-----------------------
 1 files changed, 2 insertions(+), 23 deletions(-)

diff --git a/src/image.c b/src/image.c
index c499c79..ae8ca0a 100644
--- a/src/image.c
+++ b/src/image.c
@@ -332,7 +332,7 @@
             for(x = 0; x < im.w; ++x){
                 float rx = cos(rad)*(x-cx) - sin(rad)*(y-cy) + cx;
                 float ry = sin(rad)*(x-cx) + cos(rad)*(y-cy) + cy;
-                float val = billinear_interpolate(im, rx, ry, c);
+                float val = bilinear_interpolate(im, rx, ry, c);
                 set_pixel(rot, x, y, c, val);
             }
         }
@@ -549,7 +549,7 @@
    }
  */
 
-float billinear_interpolate(image im, float x, float y, int c)
+float bilinear_interpolate(image im, float x, float y, int c)
 {
     int ix = (int) floorf(x);
     int iy = (int) floorf(y);
@@ -564,29 +564,9 @@
     return val;
 }
 
-// #wikipedia
 image resize_image(image im, int w, int h)
 {
     image resized = make_image(w, h, im.c);   
-    int r, c, k;
-    float w_scale = (float)(im.w - 1) / (w - 1);
-    float h_scale = (float)(im.h - 1) / (h - 1);
-    for(k = 0; k < im.c; ++k){
-        for(r = 0; r < h; ++r){
-            for(c = 0; c < w; ++c){
-                float sx = c*w_scale;
-                float sy = r*h_scale;
-                float val = billinear_interpolate(im, sx, sy, k);
-                set_pixel(resized, c, r, k, val);
-            }
-        }
-    }
-    return resized;
-}
-
-image resize_image2(image im, int w, int h)
-{
-    image resized = make_image(w, h, im.c);   
     image part = make_image(w, im.h, im.c);
     int r, c, k;
     float w_scale = (float)(im.w - 1) / (w - 1);
@@ -607,7 +587,6 @@
             }
         }
     }
-
     for(k = 0; k < im.c; ++k){
         for(r = 0; r < h; ++r){
             float sy = r*h_scale;

--
Gitblit v1.10.0