~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychOneliners/VecToImage.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function image = VecToImage(vec,nRows,nCols)
 
 
b'% image = VecToImage(vec,[nRows,nCols])'
 
 
b'%'
 
 
b'% Convert an image from vector to matrix format.'
 
 
b'% Image must be square for this to work properly.'
 
 
b'%'
 
 
b'% Also see ImageToVec.'
 
 
b'%'
 
 
b'% 8/13/94\t\tdhb\t\tAdded optional nRows,nCols arguments.'
 
 
b'% Figure out image size'
 
 
b'[m,n] = size(vec);'
 
 
b'if (nargin == 1)'
 
 
b'\tnRows = floor(sqrt(m));'
 
 
b'\tnCols = nRows;'
 
 
b'elseif (nRows*nCols ~= m)'
 
 
b"\terror('Passed image dimensions do not match vector size');"
 
 
b'end'
 
 
b'% Reshape it into an image'
 
 
b'image = reshape(vec,nRows,nCols);'
 
 
b'\\ No newline at end of file'
 
1
function image = VecToImage(vec,nRows,nCols)
 
2
% image = VecToImage(vec,[nRows,nCols])
 
3
%
 
4
% Convert an image from vector to matrix format.
 
5
% Image must be square for this to work properly.
 
6
%
 
7
% Also see ImageToVec.
 
8
%
 
9
% 8/13/94               dhb             Added optional nRows,nCols arguments.
 
10
 
 
11
% Figure out image size
 
12
[m,n] = size(vec);
 
13
 
 
14
if (nargin == 1)
 
15
        nRows = floor(sqrt(m));
 
16
        nCols = nRows;
 
17
elseif (nRows*nCols ~= m)
 
18
        error('Passed image dimensions do not match vector size');
 
19
end
 
20
 
 
21
% Reshape it into an image
 
22
image = reshape(vec,nRows,nCols);
 
23