Browse Source

changes in code to fix bug

Alena Schadt 10 years ago
parent
commit
d106f11281
2 changed files with 22 additions and 19 deletions
  1. 15 15
      drawBoxesToImg.m
  2. 7 4
      selectButterflies.m

+ 15 - 15
drawBoxesToImg.m

@@ -7,8 +7,7 @@ if nargin < 4
 end
 
 if nargin < 3,
-  partcolor{1}    = [255,0,0];
-  partcolor(2:20) = num2cell(repmat( [0,0,255], [19,1]),2);
+  partcolor    = [255,0,0];
 end
 
 
@@ -24,7 +23,7 @@ if ( nargout == 0)
         y1 = boxes(:,2+(i-1)*4);
         x2 = boxes(:,3+(i-1)*4);
         y2 = boxes(:,4+(i-1)*4);
-        line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','Color',partcolor{i},'linewidth',i_linewidth);
+        line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','Color',partcolor,'linewidth',i_linewidth);
       end
     end
     drawnow;
@@ -63,21 +62,22 @@ else
         i_minBottom = max ( 1 , y1-i_offset );
         i_maxTop    = min ( height, y2+i_offset);
 %         
-        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 1) = partcolor{i}(1);
-        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 2) = partcolor{i}(2);
-        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 3) = partcolor{i}(3);
+size ( imWithBoxes )
+        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 1) = partcolor(1);
+        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 2) = partcolor(2);
+        imWithBoxes( i_minBottom:y2+i_offset, i_minLeft:x1+i_offset, 3) = partcolor(3);
 %         
-        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 1) = partcolor{i}(1);
-        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 2) = partcolor{i}(2);
-        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 3) = partcolor{i}(3);
+        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 1) = partcolor(1);
+        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 2) = partcolor(2);
+        imWithBoxes( i_minBottom:i_maxTop,        x2-i_offset:i_maxRight, 3) = partcolor(3);
 %         
-        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 1) = partcolor{i}(1);
-        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 2) = partcolor{i}(2);
-        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 3) = partcolor{i}(3);
+        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 1) = partcolor(1);
+        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 2) = partcolor(2);
+        imWithBoxes( i_minBottom:y1+i_offset, x1:x2, 3) = partcolor(3);
 %         
-        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 1) = partcolor{i}(1);      
-        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 2) = partcolor{i}(2); 
-        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 3) = partcolor{i}(3); 
+        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 1) = partcolor(1);      
+        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 2) = partcolor(2); 
+        imWithBoxes( y2-i_offset:i_maxTop, x1:x2, 3) = partcolor(3); 
       end
     end
 end

+ 7 - 4
selectButterflies.m

@@ -1,4 +1,4 @@
-function selectButterflies ( s_img, s_dest ) 
+function selectButterflies ( s_img, s_dest, s_cacheDest ) 
 % function selectButterflies ( s_img, s_dest ) 
 % 
 % BRIEF
@@ -13,7 +13,10 @@ function selectButterflies ( s_img, s_dest )
 %    none
 % 
 
-   s_cacheDest = './cacheButterflies.mat';
+  if (nargin < 3) || isempty (s_cacheDest)
+    s_cacheDest = './cacheButterflies.mat';
+  end
+  
    if ( exist ( s_cacheDest ) )
        load ( s_cacheDest, 'cacheButterflies', 'i_counter' );
    end
@@ -32,14 +35,14 @@ function selectButterflies ( s_img, s_dest )
    
    %
    i_linewidth = 3;
-   partcolor{1} = [255,0,0];
+   partcolor = [255,0,0];
    
    if ( ~exist ( 'cacheButterflies' ) )
        cacheButterflies = struct( 'name', 'rectangle' ) ;
    else
        idxSameImg = strcmp ( {cacheButterflies.name}, s_img);
        bBox = {cacheButterflies.rectangle};
-       bBoxSameImg = cell2mat(bBox(idxSameImg)');
+       bBoxSameImg = cell2mat(bBox(idxSameImg));
        imWithBoxes = drawBoxesToImg(imWithBoxes, bBoxSameImg, partcolor, i_linewidth);         
    end