"Fossies" - the Fresh Open Source Software Archive

Member "sip-0.12.1/macros/test_color_classify.sce" (8 Feb 2012, 9015 Bytes) of package /linux/privat/sip-0.12.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Scilab source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 method = 'hsv_sip';
    2 run_image=%f;
    3 mydir='/tmp/'
    4 //method='distance_to_reference'
    5 
    6 
    7 // Fundamentals =======================================
    8 
    9 [label, certainty, confidence, secondary_label] = ..
   10   color_classify_single([0 0 1], method);
   11 label == 'blue'
   12 certainty == 'certain'
   13 
   14 [label, certainty, confidence, secondary_label] = ..
   15   color_classify_single([0 1 0], method);
   16 label == 'green'
   17 certainty == 'certain'
   18 
   19 [label, certainty, confidence, secondary_label] = ..
   20   color_classify_single([1 0 0], method);
   21 label == 'red'
   22 certainty == 'certain'
   23 
   24 
   25 [label, certainty, confidence, secondary_label] = ..
   26   color_classify_single([1 1 0], method);
   27 label == 'yellow'
   28 certainty == 'certain'
   29 
   30 [label, certainty, confidence, secondary_label] = ..
   31   color_classify_single([0 0 0], method);
   32 label == 'black'
   33 certainty == 'certain'
   34 
   35 [label, certainty, confidence, secondary_label] = ..
   36   color_classify_single([1 1 1], method);
   37 label == 'white'
   38 certainty == 'certain'
   39 
   40 // Perturbs =======================================
   41 
   42 [label, certainty, confidence, secondary_label] = ..
   43   color_classify_single([0.2 0.2 0.9], method);
   44 label == 'blue'
   45 certainty == 'certain'
   46 
   47 [label, certainty, confidence, secondary_label] = ..
   48   color_classify_single([0.2 0.9 0.2], method);
   49 label == 'green'
   50 certainty == 'certain'
   51 
   52 [label, certainty, confidence, secondary_label] = ..
   53   color_classify_single([0.9 0.2 0.2], method);
   54 label == 'red'
   55 certainty == 'certain'
   56 
   57 
   58 [label, certainty, confidence, secondary_label] = ..
   59   color_classify_single([0.9 0.9 0.2], method);
   60 label == 'yellow'
   61 certainty == 'certain'
   62 
   63 [label, certainty, confidence, secondary_label] = ..
   64   color_classify_single([0.2 0.15 0.2], method);
   65 label == 'black' | secondary_label == 'black'
   66 certainty == 'certain'
   67 
   68 [label, certainty, confidence, secondary_label] = ..
   69   color_classify_single([0.85 0.9 0.9], method);
   70 label == 'white'
   71 certainty == 'certain'
   72 
   73 // More ambiguous =======================================
   74 
   75 [label, certainty, confidence, secondary_label] = ..
   76   color_classify_single([254 121 164]/255, method);
   77 label == 'red'
   78 certainty == 'certain'
   79 
   80 [label, certainty, confidence, secondary_label] = ..
   81   color_classify_single([169 36 74]/255, method);
   82 label == 'red'
   83 certainty == 'certain'
   84 
   85 
   86 [label, certainty, confidence, secondary_label] = ..
   87   color_classify_single([254 121 164]/255, method);
   88 label == 'red'
   89 certainty == 'certain'
   90 
   91 [label, certainty, confidence, secondary_label] = ..
   92   color_classify_single([1 85 66]/255, method);
   93 label == 'green'
   94 certainty == 'certain'
   95 
   96 [label, certainty, confidence, secondary_label] = ..
   97   color_classify_single([65 153 122]/255, method);
   98 label == 'green'
   99 certainty == 'certain'
  100 
  101 [label, certainty, confidence, secondary_label] = ..
  102   color_classify_single([59 136 213]/255, method);
  103 label == 'blue'
  104 certainty == 'certain'
  105 
  106 [label, certainty, confidence, secondary_label] = ..
  107   color_classify_single([0 42 102]/255, method);
  108 label == 'blue'
  109 certainty == 'certain'
  110 
  111 [label, certainty, confidence, secondary_label] = ..
  112   color_classify_single([254 221 172]/255, method);
  113 label == 'yellow'
  114 
  115 [label, certainty, confidence, secondary_label] = ..
  116   color_classify_single([254 209 168]/255, method);
  117 label == 'yellow'
  118 
  119 [label, certainty, confidence, secondary_label] = ..
  120   color_classify_single([0 0 2]/255, method);
  121 label == 'black'
  122 certainty == 'certain'
  123 
  124 [label, certainty, confidence, secondary_label] = ..
  125   color_classify_single([0 1 0]/255, method);
  126 label == 'black'
  127 certainty == 'certain'
  128 
  129 [label, certainty, confidence, secondary_label] = ..
  130   color_classify_single([171 115 119]/255, method);
  131 label == 'red'
  132 certainty == 'certain'
  133 
  134 [label, certainty, confidence, secondary_label] = ..
  135   color_classify_single([187 184 177]/255, method);
  136 label == 'white'
  137 certainty == 'certain'
  138 
  139 [label, certainty, confidence, secondary_label] = ..
  140   color_classify_single([90 156 100]/255, method);
  141 label == 'green'
  142 certainty == 'certain'
  143 
  144 [label, certainty, confidence, secondary_label] = ..
  145   color_classify_single([169 160 161]/255, method);
  146 (label == 'gray' | label == 'white') &  (secondary_label == 'gray' | secondary_label == 'white')
  147 
  148 certainty ~= 'certain'
  149 
  150 [label, certainty, confidence, secondary_label] = ..
  151   color_classify_single([121 180 2]/255, method);
  152 label == 'green'
  153 certainty == 'certain'
  154 
  155 // best so far: 100% precision at coverage of 81 cases base hard
  156 
  157 // Taxa de acerto: 0.7852349 (117/149)   
  158  
  159 // Taxa de acerto com certeza: 0.9753086 (79/81) coverage: 0.5436242 (81/149)
  160 // (os 2 errados aqui sao OK certain abaixo, logo contam como certos)
  161 
  162 //certainty == 'certain'
  163 
  164 //OK !blue    black                        certain     blue-halogen-32   20   !
  165 //!                                                                        !
  166 //SHiNY!green   red     purple-pink-magenta  good guess  green-natural-06  34   !
  167 //!                                                                        !
  168 //OK GOOD EXAMPLE !green   yellow  gray                 unreliable  green-natural-09  68   !
  169 //!                                                                        !
  170 //!OK yellow  green   gray                 good guess  yellow-natural-5  81   !
  171 //!                                                                        !
  172 //OK !green   black                        certain     green-halogen-16  107  !
  173 //!                                                                        !
  174 //OK!blue    green   blue                 uncertain   blue-natural-6    110  !
  175 //!                                                                        !
  176 //OK!green   blue    black                good guess  green-halogen-11  112  !
  177 
  178 
  179 
  180 //!blue    green   gray                 unreliable  blue-halogen-27    11   !
  181 //!                                                                         !
  182 //!blue    green   gray                 unreliable  blue-halogen-2     14   !
  183 //!                                                                         !
  184 //HARD!red     green   gray                 unreliable  red-halogen-10     23   !
  185 //!                                                                         !
  186 //!blue    black   gray                 good guess  blue-halogen-25    30   !
  187 //!                                                                         !
  188 //!black   blue    gray                 good guess  black-halogen-4    35   !
  189 //!                                                                         !
  190 //!yellow  green   gray                 unreliable  yellow-halogen-7   46   !
  191 //!                                                                         !
  192 //!yellow  green   gray                 unreliable  yellow-halogen-3   64   !
  193 //!                                                                         !
  194 //!yellow  green   gray                 unreliable  yellow-halogen-11  76   !
  195 //!                                                                         !
  196 //!yellow  green   gray                 unreliable  yellow-natural-2   80   !
  197 //!                                                                         !
  198 //HARD!red     blue    gray                 good guess  red-natural-0      83   !
  199 //!                                                                         !
  200 //HARD!red     blue    gray                 good guess  red-natural-6      90   !
  201 //!                                                                         !
  202 //HARD!red     green   gray                 unreliable  red-halogen-6      98   !
  203 //!                                                                         !
  204 //HARD!blue    green   gray                 unreliable  blue-halogen-6     100  !
  205 //!                                                                         !
  206 //!blue    green                        good guess  blue-natural-18    110  !
  207 //!                                                                         !
  208 //!HARD red     green   gray                 unreliable  red-halogen-14     114  !
  209 //!                                                                         !
  210 //!HARD red     blue    gray                 good guess  red-natural-4      115  !
  211 //!                                                                         !
  212 //!HARD red     yellow  gray                 unreliable  red-halogen-2      116  !
  213 //!                                                                         !
  214 //!HARD red     green   blue                 uncertain   red-natural-8      117  !
  215 //!                                                                         !
  216 //VERY HARD!red     green   gray                 unreliable  red-halogen-17     124  !
  217 //!                                                                         !
  218 //HARD!blue    green   blue                 uncertain   blue-halogen-29    126  !
  219 
  220 
  221 if ~run_image
  222   return;
  223 end
  224 
  225 
  226 imgu=imgo(1:16:1536,1:16:2048,:);
  227 [img, cmap, uncertainty_level] = color_segmentation(imgu);
  228 
  229 imwrite(img,cmap, mydir + 'result.png');
  230 imwrite(normal(uncertainty_level), mydir + 'uncertainty.png');
  231 
  232 img(uncertainty_level > 0) = 4;
  233 imwrite(img,cmap, mydir + 'only-certain.png');