From d50ebc7fdf6543faab8c8b02d30730a9991f02b6 Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Tue, 06 Dec 2016 11:41:18 +0000
Subject: [PATCH] Fixed command line examples

---
 src/image.c |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/image.c b/src/image.c
index ad7c2d6..5a90efd 100644
--- a/src/image.c
+++ b/src/image.c
@@ -185,10 +185,16 @@
         int class = max_index(probs[i], classes);
         float prob = probs[i][class];
         if(prob > thresh){
-            //int width = pow(prob, 1./2.)*30+1;
+
             int width = im.h * .012;
+
+            if(0){
+                width = pow(prob, 1./2.)*10+1;
+                alphabet = 0;
+            }
+
             printf("%s: %.0f%%\n", names[class], prob*100);
-            int offset = class*1 % classes;
+            int offset = class*123457 % classes;
             float red = get_color(2,offset,classes);
             float green = get_color(1,offset,classes);
             float blue = get_color(0,offset,classes);
@@ -526,11 +532,8 @@
 }
 #endif
 
-void save_image(image im, const char *name)
+void save_image_png(image im, const char *name)
 {
-#ifdef OPENCV
-    save_image_jpg(im, name);
-#else
     char buff[256];
     //sprintf(buff, "%s (%d)", name, windows);
     sprintf(buff, "%s.png", name);
@@ -544,6 +547,14 @@
     int success = stbi_write_png(buff, im.w, im.h, im.c, data, im.w*im.c);
     free(data);
     if(!success) fprintf(stderr, "Failed to write image %s\n", buff);
+}
+
+void save_image(image im, const char *name)
+{
+#ifdef OPENCV
+    save_image_jpg(im, name);
+#else
+    save_image_png(im, name);
 #endif
 }
 
@@ -742,6 +753,22 @@
 #endif
 }
 
+image resize_max(image im, int max)
+{
+    int w = im.w;
+    int h = im.h;
+    if(w > h){
+        h = (h * max) / w;
+        w = max;
+    } else {
+        w = (w * max) / h;
+        h = max;
+    }
+    if(w == im.w && h == im.h) return im;
+    image resized = resize_image(im, w, h);
+    return resized;
+}
+
 image resize_min(image im, int min)
 {
     int w = im.w;

--
Gitblit v1.10.0