Debian Codegraph @

src/imageclasses/jlsetmask_lib.h

raw symbols SCIP
1 /**********************************************************************
2 jlsetmask.h: program to apply mask image (set invalid values) to raster image
3 Author(s): [email protected]
4 Copyright (C) 2016-2020 European Union (Joint Research Centre)
5
6 This file is part of jiplib.
7
8 jiplib is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 jiplib is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with jiplib. If not, see <https://www.gnu.org/licenses/>.
20 ***********************************************************************/
21 #ifndef _JLSETMASK_LIB_H_
22 #define _JLSETMASK_LIB_H_
23
24 #include "Jim.h"
25
26 template<typename T1, typename T2> void Jim::d_setMask_t(Jim& mask, Jim& other){
27 #if JIPLIB_PROCESS_IN_PARALLEL == 1
28 #pragma omp parallel for
29 #else
30 #endif
31 for(size_t iband=0;iband<nrOfBand();++iband){
32 unsigned char* pmask=0;
33 T1* pim=static_cast<T1*>(getDataPointer(iband));
34 if(mask.nrOfBand()<nrOfBand())
35 pmask=static_cast<unsigned char*>(mask.getDataPointer(0));
36 else
37 pmask=static_cast<unsigned char*>(mask.getDataPointer(iband));
38 T2* pother=0;
39 if(other.nrOfBand()<nrOfBand())
40 pother=static_cast<T2*>(other.getDataPointer(0));
41 else
42 pother=static_cast<T2*>(other.getDataPointer(iband));
43
44 for(size_t iplane=0;iplane<nrOfPlane();++iplane){
45 for(size_t index=nrOfCol()*nrOfRow()*iplane;index<nrOfCol()*nrOfRow()*(iplane+1);++index){
46 if(*pmask>0)
47 *pim=*pother;
48 ++pim;
49 ++pother;
50 ++pmask;
51 }
52 if(mask.nrOfPlane()<nrOfPlane()){
53 if(mask.nrOfBand()<nrOfBand())
54 pmask=static_cast<unsigned char*>(mask.getDataPointer(0));
55 else
56 pmask=static_cast<unsigned char*>(mask.getDataPointer(iband));
57 }
58 if(other.nrOfPlane()<nrOfPlane()){
59 if(other.nrOfBand()<nrOfBand())
60 pother=static_cast<T2*>(other.getDataPointer(0));
61 else
62 pother=static_cast<T2*>(other.getDataPointer(iband));
63 }
64 }
65 }
66 }
67
68 template<typename T> void Jim::d_setMask_t(Jim& mask, double value){
69 #if JIPLIB_PROCESS_IN_PARALLEL == 1
70 #pragma omp parallel for
71 #else
72 #endif
73 for(size_t iband=0;iband<nrOfBand();++iband){
74 unsigned char* pmask=0;
75 T* pim=static_cast<T*>(getDataPointer(iband));
76 if(mask.nrOfBand()<nrOfBand())
77 pmask=static_cast<unsigned char*>(mask.getDataPointer(0));
78 else
79 pmask=static_cast<unsigned char*>(mask.getDataPointer(iband));
80 for(size_t iplane=0;iplane<nrOfPlane();++iplane){
81 for(size_t index=nrOfCol()*nrOfRow()*iplane;index<nrOfCol()*nrOfRow()*(iplane+1);++index){
82 if(*pmask>0)
83 *pim=static_cast<T>(value);
84 ++pim;
85 ++pmask;
86 }
87 if(mask.nrOfPlane()<nrOfPlane()){
88 if(mask.nrOfBand()<nrOfBand())
89 pmask=static_cast<unsigned char*>(mask.getDataPointer(0));
90 else
91 pmask=static_cast<unsigned char*>(mask.getDataPointer(iband));
92 }
93 }
94 }
95 }
96
97 #endif // _JLSETMASK_LIB_H