Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

vl_imarray.m: fixes a bug causing a window to be opened all the times

  • Loading branch information...
commit 46d9544bd9a35e427e640adbc37fe3d213fd1c0b 1 parent a3fe91f
@vedaldi vedaldi authored
Showing with 35 additions and 13 deletions.
  1. +16 −10 toolbox/imop/vl_imarray.m
  2. +19 −3 toolbox/xtest/vl_test_imarray.m
View
26 toolbox/imop/vl_imarray.m
@@ -4,33 +4,36 @@
% images A. A can be either a M*N*K array, storing one gray-scale
% image per slice, or a M*N*3*K or M*N*K*3 array, storing one RGB
% image per slice. The function returns an image J which is a tiling
-% of the images in the array. Tiles are arranged from left to
-% right and top to bottom.
+% of the images in the array. Tiles are filled from left to right
+% and top to bottom.
%
-% VL_IMARRAY(...) display the image J rather than returning it.
+% VL_IMARRAY(...) displays the image J rather than returning it.
%
% VL_IMARRAY() accepts the following options:
%
% Spacing:: 0
-% Orlates the images with a null border of the specified width.
+% Separate the images by a border of the specified width (the
+% border is assigned 0 value, which usually corresponds to black).
%
% Layout:: []
% Specify a vector [TM TN] with the number of rows and columns of
% the tiling. If equal to [] the layout is computed automatically.
%
-% Movie:: 0
-% Display/returns a movie rather than generating a tyling.
+% Movie:: false
+% Display/return a movie rather than generating a tiling.
%
% CMap:: []
-% Specify a colormap for indexed images and movies.
+% Specify a colormap to construct a movie when the input is an
+% indexed image array. If not specified, MATLAB default colormap
+% is used.
%
% Reverse:: true
-% Starts filling from the bottom rather than from the top.
+% Start filling the grid from the bottom rather than from the top.
%
% See also VL_IMARRAYSC(), VL_HELP().
% AUTORIGHTS
-% Copyright (C) 2007-10 Andrea Vedaldi and Brian Fulkerson
+% Copyright (C) 2007-11 Andrea Vedaldi and Brian Fulkerson
%
% This file is part of VLFeat, available under the terms of the
% GNU GPLv2, or (at your option) any later version.
@@ -39,7 +42,7 @@
opts.spacing = 0 ;
opts.layout = [] ;
opts.movie = false ;
-opts.cmap = colormap ;
+opts.cmap = [] ;
opts = vl_argparse(opts, varargin) ;
swap3 = false ;
@@ -102,6 +105,9 @@
jr = j * (width + opts.spacing) + (1:width) ;
cdata(ir,jr,:) = tmp ;
else
+ if isempty(opts.cmap)
+ opts.cmap = get(0, 'DefaultFigureColormap') ;
+ end
MOV(k) = im2frame(tmp, opts.cmap) ;
end
end
View
22 toolbox/xtest/vl_test_imarray.m
@@ -2,13 +2,30 @@
% VL_TEST_IMARRAY
vl_test_init ;
-function test_basic(s)
+function test_movie_rgb(s)
+A = rand(23,15,3,4) ;
+B = vl_imarray(A,'movie',true) ;
+
+function test_movie_indexed(s)
+cmap = get(0,'DefaultFigureColormap') ;
+A = uint8(size(cmap,1)*rand(23,15,4)) ;
+A = min(A,size(cmap,1)-1) ;
+B = vl_imarray(A,'movie',true) ;
+
+function test_movie_gray_indexed(s)
+A = uint8(255*rand(23,15,4)) ;
+B = vl_imarray(A,'movie',true,'cmap',gray(256)) ;
+
+for k=1:size(A,3)
+ vl_assert_equal(squeeze(A(:,:,k)), ...
+ frame2im(B(k))) ;
+end
+function test_basic(s)
M = 3 ;
N = 4 ;
width = 32 ;
height = 15 ;
-
for i=1:M
for j=1:N
A{i,j} = rand(width,height) ;
@@ -18,5 +35,4 @@ function test_basic(s)
A1 = cat(3,A1{:}) ;
A2 = cell2mat(A) ;
B = vl_imarray(A1, 'layout', [M N]) ;
-
vl_assert_equal(A2,B) ;
Please sign in to comment.
Something went wrong with that request. Please try again.