| 1 | % 'ima_green': take the gree component of a color image
|
|---|
| 2 | %------------------------------------------------------------------------
|
|---|
| 3 | %%%% Use the general syntax for transform fields with a single input %%%%
|
|---|
| 4 | % OUTPUT:
|
|---|
| 5 | % DataOut: output field structure
|
|---|
| 6 | %
|
|---|
| 7 | %INPUT:
|
|---|
| 8 | % DataIn: first input field structure
|
|---|
| 9 |
|
|---|
| 10 | %=======================================================================
|
|---|
| 11 | % Copyright 2008-2024, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
|
|---|
| 12 | % http://www.legi.grenoble-inp.fr
|
|---|
| 13 | % Joel.Sommeria - Joel.Sommeria (A) univ-grenoble-alpes.fr
|
|---|
| 14 | %
|
|---|
| 15 | % This file is part of the toolbox UVMAT.
|
|---|
| 16 | %
|
|---|
| 17 | % UVMAT is free software; you can redistribute it and/or modify
|
|---|
| 18 | % it under the terms of the GNU General Public License as published
|
|---|
| 19 | % by the Free Software Foundation; either version 2 of the license,
|
|---|
| 20 | % or (at your option) any later version.
|
|---|
| 21 | %
|
|---|
| 22 | % UVMAT is distributed in the hope that it will be useful,
|
|---|
| 23 | % but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 24 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 25 | % GNU General Public License (see LICENSE.txt) for more details.
|
|---|
| 26 | %=======================================================================
|
|---|
| 27 |
|
|---|
| 28 | function DataOut=ima_rescale(DataIn,Param)
|
|---|
| 29 |
|
|---|
| 30 | %% request input parameters
|
|---|
| 31 | if isfield(DataIn,'Action') && isfield(DataIn.Action,'RUN') && isequal(DataIn.Action.RUN,0)
|
|---|
| 32 | prompt = {'SaturationValue'};
|
|---|
| 33 | dlg_title = 'get the maximum image value';
|
|---|
| 34 | num_lines= 1;
|
|---|
| 35 | def = { '1024'};
|
|---|
| 36 | if isfield(Param,'TransformInput')&&isfield(Param.TransformInput,'SaturationValue')
|
|---|
| 37 | def={num2str(Param.TransformInput.SaturationValue)};
|
|---|
| 38 | end
|
|---|
| 39 | answer = inputdlg(prompt,dlg_title,num_lines,def);
|
|---|
| 40 | DataOut.TransformInput.SaturationValue=str2num(answer{1}); %size of the filtering window
|
|---|
| 41 | return
|
|---|
| 42 | end
|
|---|
| 43 |
|
|---|
| 44 | Coeff=Param.TransformInput.SaturationValue;
|
|---|
| 45 | DataOut=DataIn; %default
|
|---|
| 46 | if isfield(DataOut,'A')
|
|---|
| 47 | DataOut.A=uint16(Coeff*tanh(double(DataOut.A)/Coeff));
|
|---|
| 48 | end
|
|---|
| 49 | if isfield(DataOut,'ImageA')
|
|---|
| 50 | DataOut.ImageA=uint16(Coeff*tanh(double(DataOut.ImageA)/Coeff));
|
|---|
| 51 | end
|
|---|
| 52 | if isfield(DataOut,'ImageB')
|
|---|
| 53 | DataOut.ImageB=uint16(Coeff*tanh(double(DataOut.ImageB)/Coeff));
|
|---|
| 54 | end
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|