The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

drawBox.m

Go to the documentation of this file.
00001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00002 function boxed = drawBox(boxed, tr, br, lc, rc, boxType, offset)
00003 % Draw an individual box into an image.  Input the image, the edges of the
00004 % box, and the type of box (color).  Options for boxType are 
00005 %   'hit'    -- black and white box
00006 %   'FA'     -- red box (I use them for false alarms)
00007 %   'FAheur' -- green box (I use them to show suppressed boxes) 
00008 %   
00009   if nargin == 6
00010     offset = 0;
00011   end
00012   s = round(max([br-tr,rc-lc])/24);
00013   tr = tr+offset*s;
00014   br = br-offset*s;
00015   lc = lc+offset*s;
00016   rc = rc-offset*s;
00017   
00018   if max(max(max(boxed))) > 1,
00019     maxColor = 255;
00020   else
00021     maxColor = 1;
00022   end
00023   if ndims(boxed) < 3
00024     img = boxed;
00025     [rows,cols] = size(boxed);
00026     boxed = zeros(rows,cols,3);
00027     boxed(:,:,1) = img;
00028     boxed(:,:,2) = img;
00029     boxed(:,:,3) = img;
00030   end
00031   [rows,cols,nd] = size(boxed);
00032   tr = max([tr,1]);
00033   br = min([br,rows]);
00034   lc = max([lc,1]);
00035   rc = min([rc,cols]);
00036   switch boxType
00037    case 'hit'
00038     boxed(tr+2,lc:rc,:) = maxColor;
00039     boxed(br-2,lc:rc,:) = maxColor;
00040     boxed(tr:br,lc+2,:) = maxColor;
00041     boxed(tr:br,rc-2,:) = maxColor;
00042     boxed(tr+1,lc:rc,:) = 0;
00043     boxed(br-1,lc:rc,:) = 0;
00044     boxed(tr:br,lc+1,:) = 0;
00045     boxed(tr:br,rc-1,:) = 0;
00046     boxed(tr,lc:rc,:) = maxColor;
00047     boxed(br,lc:rc,:) = maxColor;
00048     boxed(tr:br,lc,:) = maxColor;
00049     boxed(tr:br,rc,:) = maxColor;
00050    case 'FA'
00051     boxed(tr,lc:rc,1) = maxColor;
00052     boxed(br,lc:rc,1) = maxColor;
00053     boxed(tr:br,lc,1) = maxColor;
00054     boxed(tr:br,rc,1) = maxColor;
00055    case 'FAheur'
00056     boxed(tr,lc:rc,2) = maxColor;
00057     boxed(br,lc:rc,2) = maxColor;
00058     boxed(tr:br,lc,2) = maxColor;
00059     boxed(tr:br,rc,2) = maxColor;
00060    case 'magenta'
00061     boxed(tr,lc:rc,1) = maxColor;
00062     boxed(br,lc:rc,1) = maxColor;
00063     boxed(tr:br,lc,1) = maxColor;
00064     boxed(tr:br,rc,1) = maxColor;
00065     boxed(tr,lc:rc,3) = maxColor;
00066     boxed(br,lc:rc,3) = maxColor;
00067     boxed(tr:br,lc,3) = maxColor;
00068     boxed(tr:br,rc,3) = maxColor;
00069   end    

Generated on Mon Nov 8 17:07:32 2004 for MPT by  doxygen 1.3.9.1