showboxes.m 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. function figHandle = showboxes(im, boxes, partcolor, b_WnHgiven)
  2. % showboxes(im, boxes)
  3. % Draw boxes on top of image.
  4. if ( nargin < 4 )
  5. b_WnHgiven = false;
  6. end
  7. if ( (nargin < 3) || isempty ( partcolor) )
  8. partcolor(1) = {'r'};
  9. partcolor(2:20) = {'b'};
  10. end
  11. %imagesc(im); axis image; axis off;
  12. handle = imshow(im);
  13. hold on;
  14. if ~isempty(boxes)
  15. numparts = floor(size(boxes, 2)/4);
  16. for i = 1:numparts
  17. x1 = boxes(:,1+(i-1)*4);
  18. y1 = boxes(:,2+(i-1)*4);
  19. if ( b_WnHgiven )
  20. x2 = x1+boxes(:,3+(i-1)*4);
  21. y2 = y1+boxes(:,4+(i-1)*4);
  22. else
  23. x2 = boxes(:,3+(i-1)*4);
  24. y2 = boxes(:,4+(i-1)*4);
  25. end
  26. line([x1 x1 x2 x2 x1]',[y1 y2 y2 y1 y1]','color',partcolor{i},'linewidth',5);
  27. end
  28. end
  29. drawnow;
  30. hold off;
  31. if ( nargout > 0 )
  32. figHandle = handle;
  33. end