source: trunk/loci/visbio/convert.m @ 485

Revision 485, 976 bytes checked in by curtis, 15 years ago (diff)

Move M files to main VisBio folder; update version number and what's new.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[485]1function [result] = convert(pix, params)
2%convert applies a multiplier and an offset to the image planes
3%
4%  pix    - a 3D array of pixels dimensioned (Y, X, N)
5%  params - multiplier, offset
6
7if size(pix, 1) == 0
8  if size(params, 1) == 0
9    % return parameter list with default values
10    result{1} = {'Multiplier', 1.0};
11    result{2} = {'Offset', 0.0};
12  else
13    % input dimensions must be prepended to parameter list
14    leny = params(1);
15    lenx = params(2);
16    num = params(3);
17
18    % mult and offset do not affect output dimensions,
19    % but if they did, it would be permitted
20    mult = params(4);
21    offset = params(5);
22
23    % return output image dimensions for the given
24    % input dimensions and parameter values
25    result = [leny lenx num];
26  end
27else
28  % assign parameters
29  mult = params(1);
30  offset = params(2);
31
32  % process pixels
33  leny = size(pix, 1);
34  lenx = size(pix, 2);
35  num = size(pix, 3);
36  result(:,:,:) = mult * pix(:,:,:) + offset;
37end
Note: See TracBrowser for help on using the repository browser.