Ignore:
Timestamp:
Apr 21, 2023, 11:01:06 AM (13 months ago)
Author:
sommeria
Message:

various updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/transform_field/ima_filter.m

    r1119 r1122  
    1 % 'ima_filter': example of image transform with input parameters: low-pass filter of an image
     1% 'ima_filter': low-pass filter of an image or other 2D fields defined on a regular grid
     2% the size of the filtering window in x and y is interactivement defined
    23
    34%------------------------------------------------------------------------
    45%%%%  Use the general syntax for transform fields with a single input and parameters %%%%
    5 % OUTPUT: 
    6 % DataOut:   output field structure 
     6% OUTPUT:
     7% DataOut:   output field structure
    78%
    89%INPUT:
    910% DataIn:  input field structure
     11%
    1012% Param: matlab structure whose field Param.TransformInput contains the filter parameters
     13% DataIn_1: variables possibly introduced as a second input field
    1114%-----------------------------------
    1215
     
    7881if exist('DataIn_1','var')
    7982    [CellInfo,NbDim,errormsg]=find_field_cells(DataIn_1);
    80 for icell=1:numel(CellInfo)
    81     if isfield(CellInfo{icell},'CoordType')&& strcmp(CellInfo{icell}.CoordType,'grid')
    82         for ivar=1:numel(CellInfo{icell}.VarIndex)
    83             VarName=DataIn_1.ListVarName{CellInfo{icell}.VarIndex(ivar)};
    84             Atype=class(DataIn_1.(VarName));% detect integer 8 or 16 bits
    85             if numel(size(DataIn_1.(VarName)))==3
    86                 DataOut.(VarName)=filter2(Mfiltre,sum(DataIn_1.(VarName),3));%filter the input image, after summation on the color component (for color images)
    87                 DataOut.(VarName)=uint16(DataOut.(VarName)); %transform to 16 bit images
    88             else
    89                 DataOut.(VarName)=filter2(Mfiltre,DataIn_1.(VarName));
    90                 DataOut.(VarName)=feval(Atype,DataOut.(VarName));%transform to the initial image format
     83    for icell=1:numel(CellInfo)
     84        if isfield(CellInfo{icell},'CoordType')&& strcmp(CellInfo{icell}.CoordType,'grid')
     85            for ivar=1:numel(CellInfo{icell}.VarIndex)
     86                VarName=DataIn_1.ListVarName{CellInfo{icell}.VarIndex(ivar)};
     87                Atype=class(DataIn_1.(VarName));% detect integer 8 or 16 bits
     88                if numel(size(DataIn_1.(VarName)))==3
     89                    DataOut.(VarName)=filter2(Mfiltre,sum(DataIn_1.(VarName),3));%filter the input image, after summation on the color component (for color images)
     90                    DataOut.(VarName)=uint16(DataOut.(VarName)); %transform to 16 bit images
     91                else
     92                    DataOut.(VarName)=filter2(Mfiltre,DataIn_1.(VarName));
     93                    DataOut.(VarName)=feval(Atype,DataOut.(VarName));%transform to the initial image format
     94                end
    9195            end
    9296        end
    9397    end
    9498end
    95 end
    9699
    97100 
Note: See TracChangeset for help on using the changeset viewer.