| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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 |