39 double K =
PI / (r2 -
r1);
44 double k2=(
k -
z0) * (
k - z0);
47 double i2_k2=k2+(
i -
y0) * (
i - y0);
50 double r2=i2_k2+(
j -
x0) * (
j - x0);
56 A3D_ELEM(mask,
k,
i,
j) = 0.5*(1 + cos(K * (r - r1)));
68 double r1,
double r2,
double pix_width,
int mode,
69 double x0,
double y0,
double z0)
89 double A = -20 *
log10(delta);
90 int M =
CEIL((A - 8) / (2.285 * Deltaw));
93 beta = 0.1102 * (A - 8.7);
95 beta = 0.5842 * pow(A - 21, 0.4) + 0.07886 * (A - 21);
105 else if (
ZSIZE(mask)==1)
108 mask.
resize(2*M + 1, 2*M + 1);
113 mask.
resize(2*M + 1, 2*M + 1, 2*M + 1);
117 double iI0Beta = 1.0 /
bessi0(beta);
120 double r =
sqrt((
double)(
i *
i +
j *
j +
k *
k));
128 double omega,
int mode,
double x0,
double y0,
double z0)
132 double r =
sqrt( (
k - z0) * (
k - z0) + (
i - y0) * (
i - y0) + (
j - x0) * (
j - x0) );
140 double omega,
double delta,
double Deltaw)
152 double x0,
double y0,
double z0)
159 double r =
sqrt((
k - z0) * (
k - z0) / Zdim2 + (
i - y0) * (
i - y0) / Xdim2 + (
j - x0) * (
j - x0) / Ydim2);
160 A3D_ELEM(mask,
k,
i,
j) = 0.42 + 0.5 * cos(2 *
PI * r) + 0.08 * cos(4 *
PI * r);
167 double omega,
double power_percentage,
168 double x0,
double y0,
double z0)
172 int N =
CEIL(1 / omega *
CEIL(-1 / 2 + 1 / (
PI * (1 - power_percentage / 100))));
194 double radius,
int mode,
double x0,
double y0,
double z0)
197 double radius2 = radius * radius;
205 double z2y2=z2+diff*diff;
209 double r2 = z2y2+diff*diff;
221 double x0,
double y0,
double z0)
225 double r =
sqrt((
k - z0) * (
k - z0) + (
i - y0) * (
i - y0) + (
j - x0) * (
j - x0));
245 double R1,
double R2,
int mode,
double x0,
double y0,
double z0)
248 double R12 = R1 * R1;
249 double R22 = R2 * R2;
252 double r2 = (
k -
z0) * (
k - z0) + (
i -
y0) * (
i - y0) + (
j -
x0) * (
j - x0);
253 bool in_crown = (r2 >= R12 && r2 <= R22);
265 double R12 = R1 * R1;
266 double R22 = R2 * R2;
269 double r2 = (
i -
y0) * (
i - y0) + (
j -
x0) * (
j - x0);
270 bool in_tube = (r2 >= R12 && r2 <= R22 &&
ABS(
k)<H);
280 double x0,
double y0,
double z0)
326 double sigma,
int mode,
double x0,
double y0,
double z0)
328 double sigma2 = sigma * sigma;
330 double K = 1. / pow(
sqrt(2.*
PI)*sigma,(
double)mask.
getDim());
334 double r2 = (
k -
z0) * (
k - z0) + (
i -
y0) * (
i - y0) + (
j -
x0) * (
j - x0);
335 A3D_ELEM(mask,
k,
i,
j) = K * exp(-0.5 * r2 / sigma2);
346 #define DWTCIRCULAR2D_BLOCK(s,quadrant) \ 347 SelectDWTBlock(s, mask, quadrant, \ 348 XX(corner1),XX(corner2),YY(corner1),YY(corner2)); \ 349 V2_PLUS_V2(center,corner1,corner2); \ 350 V2_BY_CT(center,center,0.5); \ 351 FOR_ALL_ELEMENTS_IN_ARRAY2D_BETWEEN(corner1,corner2) { \ 352 double r2=(XX(r)-XX(center))*(XX(r)-XX(center))+ \ 353 (YY(r)-YY(center))*(YY(r)-YY(center)); \ 354 A2D_ELEM(mask,YY(r),XX(r))=(r2<=radius2); \ 357 int smin,
int smax,
const std::string &quadrant)
359 double radius2 = radius * radius / (4 * (smin + 1));
361 for (
int s = smin; s <= smax; s++)
367 if (quadrant ==
"xx")
380 double omega,
double delta,
double Deltaw)
387 double A = -20 *
log10(delta);
388 double M =
CEIL((A - 8) / (2.285 * Deltaw));
391 beta = 0.1102 * (A - 8.7);
393 beta = 0.5842 * pow(A - 21, 0.4) + 0.07886 * (A - 21);
398 mask.
resize((
size_t)(2*M + 1),(
size_t)(2*M + 1));
400 double iI0Beta = 1.0 /
bessi0(beta);
404 bessi0(beta *
sqrt((
double)(1 - (i / M) * (i / M)))) * iI0Beta *
405 bessi0(beta *
sqrt((
double)(1 - (j / M) * (j / M)))) * iI0Beta;
413 mask(0, 1) = mask(1, 0) = mask(1, 2) = mask(2, 1) = value;
421 mask(0, 1) = mask(1, 0) = mask(1, 2) = mask(2, 1) = value1;
422 mask(0, 0) = mask(0, 2) = mask(2, 0) = mask(2, 2) = value2;
431 #define DWTSPHERICALMASK_BLOCK(s,quadrant) \ 432 SelectDWTBlock(s, mask, quadrant, \ 433 XX(corner1),XX(corner2),YY(corner1),YY(corner2), \ 434 ZZ(corner1),ZZ(corner2)); \ 435 V3_PLUS_V3(center,corner1,corner2); \ 436 V3_BY_CT(center,center,0.5); \ 437 FOR_ALL_ELEMENTS_IN_ARRAY3D_BETWEEN(corner1,corner2) { \ 438 double r2=(XX(r)-XX(center))*(XX(r)-XX(center))+ \ 439 (YY(r)-YY(center))*(YY(r)-YY(center))+ \ 440 (ZZ(r)-ZZ(center))*(ZZ(r)-ZZ(center)); \ 441 A3D_ELEM(mask,ZZ(r),YY(r),XX(r))=(r2<=radius2); \ 444 int smin,
int smax,
const std::string &quadrant)
447 double radius2 = radius * radius / (4 * (smin + 1));
448 for (
int s = smin; s <= smax; s++)
454 if (quadrant ==
"xxx")
472 double R,
double H,
int mode,
double x0,
double y0,
double z0)
479 double r2 = (
i -
y0) * (
i - y0) + (
j -
x0) * (
j - x0);
480 int in_cyilinder = (r2 <= R2 &&
ABS(
k - z0) <= H_2);
490 int halfX = mask.
xdim/2;
491 int halfY = mask.
ydim/2;
492 int halfZ = mask.
zdim/2;
498 int maxX = (int)((mask.
xdim-0.5)/2);
499 int maxY = (int)((mask.
ydim-0.5)/2);
500 int maxZ = (int)((mask.
zdim-0.5)/2);
514 double rad = tan(
PI * theta / 180.) * (double)
k;
515 if ((
double)(
i*
i +
j*
j) < (rad*rad))
527 int halfX = mask.
xdim/2;
528 int halfY = mask.
ydim/2;
529 int halfZ = mask.
zdim/2;
535 int maxX = (int)((mask.
xdim-0.5)/2);
536 int maxY = (int)((mask.
ydim-0.5)/2);
537 int maxZ = (int)((mask.
zdim-0.5)/2);
539 auto tg0 = -tan(
PI * (-90. - thetaF) / 180.);
540 auto tgF = -tan(
PI * (90. - theta0) / 180.);
565 auto limx0 = tg0 * zp;
566 auto limxF = tgF * zp;
569 if (xp <= limx0 || xp >= limxF)
578 if (xp <= limxF || xp >= limx0)
593 mask(1, 1, 1) = center;
594 mask(1, 1, 0) = mask(1, 1, 2) = mask(0, 1, 1) = mask(2, 1, 1) = mask(1, 0, 1) = mask(1, 2, 1) = value;
602 mask(1, 1, 1) = center;
604 mask(1, 1, 0) = mask(1, 1, 2) = mask(0, 1, 1) = mask(2, 1, 1) = mask(1, 0, 1) = mask(1, 2, 1) = value1;
606 mask(0, 1, 0) = mask(0, 0, 1) = mask(0, 1, 2) = mask(0, 2, 1) = value2;
607 mask(1, 0, 0) = mask(1, 2, 0) = mask(1, 0, 2) = mask(1, 2, 2) = value2;
608 mask(2, 1, 0) = mask(2, 0, 1) = mask(2, 1, 2) = mask(2, 2, 1) = value2;
617 mask(1, 1, 1) = center;
619 mask(1, 1, 0) = mask(1, 1, 2) = mask(0, 1, 1) = mask(2, 1, 1) = mask(1, 0, 1) = mask(1, 2, 1) = value1;
621 mask(0, 1, 0) = mask(0, 0, 1) = mask(0, 1, 2) = mask(0, 2, 1) = value2;
622 mask(1, 0, 0) = mask(1, 2, 0) = mask(1, 0, 2) = mask(1, 2, 2) = value2;
623 mask(2, 1, 0) = mask(2, 0, 1) = mask(2, 1, 2) = mask(2, 2, 1) = value2;
625 mask(0, 0, 0) = mask(0, 0, 2) = mask(0, 2, 0) = mask(0, 2, 2) = value3;
626 mask(2, 0, 0) = mask(2, 0, 2) = mask(2, 2, 0) = mask(2, 2, 2) = value3;
726 if (strcmp(argv[i+1],
"circular") == 0)
745 else if (strcmp(argv[i+1],
"DWT_circular") == 0)
758 else if (strcmp(argv[i+1],
"rectangular") == 0)
769 if (argv[i+4][0] !=
'-')
788 else if (strcmp(argv[i+1],
"cone") == 0)
805 else if (strcmp(argv[i+1],
"wedge") == 0)
816 else if (strcmp(argv[i+1],
"crown") == 0)
824 if (
R1 < 0 &&
R2 < 0)
830 else if (
R1 > 0 &&
R2 > 0)
837 else if (strcmp(argv[i+1],
"cylinder") == 0)
851 else if (
R1 > 0 &&
H > 0)
858 else if (strcmp(argv[i+1],
"tube") == 0)
867 if (
R1 < 0 &&
R2 < 0 &&
H<0)
874 else if (
R1 > 0 &&
R2 > 0 &&
H>0)
881 else if (strcmp(argv[i+1],
"gaussian") == 0)
898 else if (strcmp(argv[i+1],
"raised_cosine") == 0)
906 if (
R1 < 0 &&
R2 < 0)
912 else if (
R1 > 0 &&
R2 > 0)
919 else if (strcmp(argv[i+1],
"raised_crown") == 0)
928 if (
R1 < 0 &&
R2 < 0)
934 else if (
R1 > 0 &&
R2 > 0)
941 else if (strcmp(argv[i+1],
"blob_circular") == 0)
962 else if (strcmp(argv[i+1],
"blob_crown") == 0)
984 else if (strcmp(argv[i+1],
"blackman") == 0)
990 else if (strcmp(argv[i+1],
"sinc") == 0)
1006 else if (strcmp(argv[i+1],
"binary_file") == 0)
1011 else if (strcmp(argv[i+1],
"real_file") == 0)
1024 if (mode==INNER_MASK) std::cout << " mode=INNER MASK\n"; \ 1025 else std::cout << " mode=OUTER MASK\n"; 1026 #define SHOW_CENTER \ 1027 std::cout << " (x0,y0,z0)=(" << x0 << "," << y0 << "," << z0 << ")\n"; 1031 std::cout <<
"Mask type: No mask\n";
1034 std::cout <<
"Mask type: Binary circular\n" 1035 <<
" R=" <<
R1 << std::endl;
1040 std::cout <<
"Mask type: Binary DWT circular\n" 1041 <<
" R=" <<
R1 << std::endl
1042 <<
" smin=" <<
smin << std::endl
1043 <<
" smax=" <<
smax << std::endl
1044 <<
" quadrant=" <<
quadrant << std::endl;
1047 std::cout <<
"Mask type: Binary crown\n" 1048 <<
" R1=" <<
R1 << std::endl
1049 <<
" R2=" <<
R2 << std::endl;
1054 std::cout <<
"Mask type: Cylinder\n" 1055 <<
" R1=" <<
R1 << std::endl
1056 <<
" H=" <<
H << std::endl;
1061 std::cout <<
"Mask type: Tube\n" 1062 <<
" R1=" <<
R1 << std::endl
1063 <<
" R2=" <<
R2 << std::endl
1064 <<
" H=" <<
H << std::endl;
1069 std::cout <<
"Mask type: Frame\n" 1070 <<
" Xrect=" <<
Xrect << std::endl
1071 <<
" Yrect=" <<
Yrect << std::endl;
1076 std::cout <<
"Mask type: Gaussian\n" 1077 <<
" sigma=" <<
sigma << std::endl;
1082 std::cout <<
"Mask type: Raised cosine\n" 1083 <<
" R1=" <<
R1 << std::endl
1084 <<
" R2=" <<
R2 << std::endl;
1089 std::cout <<
"Mask type: Raised crown\n" 1090 <<
" R1=" <<
R1 << std::endl
1091 <<
" R2=" <<
R2 << std::endl
1092 <<
" pixwidth=" <<
pix_width << std::endl;
1097 std::cout <<
"Mask type: Blob circular\n" 1098 <<
" R1=" <<
R1 << std::endl
1101 <<
" blob alpha=" <<
blob_alpha << std::endl;
1106 std::cout <<
"Mask type: Blob crown\n" 1107 <<
" R1=" <<
R1 << std::endl
1108 <<
" R2=" <<
R2 << std::endl
1111 <<
" blob alpha=" <<
blob_alpha << std::endl;
1116 std::cout <<
"Mask type: Blackman\n";
1121 std::cout <<
"Mask type: Sinc\n" 1122 <<
" w=" <<
omega << std::endl;
1127 std::cout <<
"Mask type: Read from disk\n" 1128 <<
" File=" <<
fn_mask << std::endl;
1136 std::cerr <<
"Mask usage:\n";
1137 std::cerr <<
" [-center <x0=0> <y0=0> <z0=0>]: Center of the mask\n";
1139 std::cerr <<
" [-mask circular <R> : circle/sphere mask\n" 1140 <<
" if R>0 => outside R\n" 1141 <<
" if R<0 => inside R\n" 1142 <<
" [-mask DWT_circular <R> <smin> <smax>: circle/sphere mask\n" 1143 <<
" smin and smax define the scales\n" 1145 <<
" |-mask rectangular <Xrect> <Yrect> [<Zrect>]: 2D or 3D rectangle\n" 1146 <<
" if X,Y,Z > 0 => outside rectangle\n" 1147 <<
" if X,Y,Z < 0 => inside rectangle\n" 1148 <<
" |-mask crown <R1> <R2> : 2D or 3D crown\n" 1149 <<
" if R1,R2 > 0 => outside crown\n" 1150 <<
" if R1,R2 < 0 => inside crown\n" 1151 <<
" |-mask cylinder <R> <H> : 2D circle or 3D cylinder\n" 1152 <<
" if R,H > 0 => outside cylinder\n" 1153 <<
" if R,H < 0 => inside cylinder\n" 1154 <<
" |-mask tube <R1> <R2> <H> : 2D or 3D tube\n" 1155 <<
" if R1,R2,H > 0 => outside tube\n" 1156 <<
" if R1,R2,H < 0 => inside tube\n" 1157 <<
" |-mask cone <theta> : 3D cone (parallel to Z) \n" 1158 <<
" if theta > 0 => outside cone\n" 1159 <<
" if theta < 0 => inside cone\n" 1160 <<
" |-mask wedge <th0> <thF> : 3D missing-wedge mask for data \n" 1161 <<
" collected between tilting angles \n" 1162 <<
" th0 and thF (around the Y-axis) \n" 1163 <<
" |-mask <binary file> : Read from file\n" 1166 std::cerr <<
" |-mask gaussian <sigma> : 2D or 3D gaussian\n" 1167 <<
" if sigma > 0 => outside gaussian\n" 1168 <<
" if sigma < 0 => inside gaussian\n" 1169 <<
" |-mask raised_cosine <R1> <R2>: 2D or 3D raised_cosine\n" 1170 <<
" if R1,R2 > 0 => outside sphere\n" 1171 <<
" if R1,R2 < 0 => inside sphere\n" 1172 <<
" |-mask raised_crown <R1> <R2> <pixwidth>: 2D or 3D raised_crown\n" 1173 <<
" if R1,R2 > 0 => outside crown\n" 1174 <<
" if R1,R2 < 0 => inside crown\n" 1175 <<
" |-mask blob_circular <R1> <blob_radius>: 2D or 3D blob circular\n" 1176 <<
" if blob_radius > 0 => outside blob\n" 1177 <<
" if blob_radius < 0 => inside blob\n" 1178 <<
" |-mask blob_crown <R1> <R2> <blob_radius>: 2D or 3D blob_crown\n" 1179 <<
" if blob_radius > 0 => outside crown\n" 1180 <<
" if blob_radius < 0 => inside crown\n" 1181 <<
" [ -m <blob_order=2> : Order of blob\n" 1182 <<
" [ -a <blob_alpha=10.4> : Alpha of blob\n" 1183 <<
" |-mask blackman : 2D or 3D Blackman mask\n" 1184 <<
" always inside blackman\n" 1185 <<
" |-mask sinc <w>] : 2D or 3D sincs\n" 1186 <<
" if w > 0 => outside sinc\n" 1187 <<
" if w < 0 => inside sinc\n" 1204 const char* prefix,
const char* comment,
bool moreOptions)
1207 char tempLine2[512];
1212 if(prefix ==
nullptr)
1213 sprintf(tempLine,
" [--mask%c <mask_type=circular>] ",advanced);
1215 sprintf(tempLine,
"%s --mask%c <mask_type=circular> ", prefix,advanced);
1216 if (comment !=
nullptr)
1217 sprintf(tempLine2,
"%s : %s", tempLine, comment);
1219 strcpy(tempLine2,tempLine);
1226 program->
addParamsLine(
" circular <R> : circle/sphere mask");
1229 program->
addParamsLine(
" DWT_circular <R> <smin> <smax>: circle/sphere mask");
1230 program->
addParamsLine(
" : smin and smax define the scales to be kept");
1231 program->
addParamsLine(
" rectangular <Xrect> <Yrect> <Zrect=-1>: 2D or 3D rectangle");
1232 program->
addParamsLine(
" :if X,Y,Z > 0 => outside rectangle");
1233 program->
addParamsLine(
" :if X,Y,Z < 0 => inside rectangle");
1234 program->
addParamsLine(
" crown <R1> <R2> : 2D or 3D crown");
1237 program->
addParamsLine(
" cylinder <R> <H> : 2D circle or 3D cylinder");
1243 program->
addParamsLine(
" cone <theta> : 3D cone (parallel to Z) ");
1246 program->
addParamsLine(
" wedge <th0> <thF> : 3D missing-wedge mask for data ");
1247 program->
addParamsLine(
" :collected between tilting angles ");
1248 program->
addParamsLine(
" :th0 and thF (around the Y-axis) ");
1249 program->
addParamsLine(
" binary_file <binary_file> : Read from file and cast to binary");
1254 program->
addParamsLine(
" real_file <float_file> : Read from file and do not cast");
1255 program->
addParamsLine(
" gaussian <sigma> : 2D or 3D gaussian");
1256 program->
addParamsLine(
" :if sigma > 0 => outside gaussian");
1257 program->
addParamsLine(
" : if sigma < 0 => inside gaussian");
1258 program->
addParamsLine(
" raised_cosine <R1> <R2>: 2D or 3D raised_cosine");
1259 program->
addParamsLine(
" : if R1,R2 > 0 => outside sphere");
1261 program->
addParamsLine(
" raised_crown <R1> <R2> <pixwidth>: 2D or 3D raised_crown");
1262 program->
addParamsLine(
" : if R1,R2 > 0 => outside sphere");
1264 program->
addParamsLine(
" blob_circular <R1> <blob_radius>: 2D or 3D blob circular");
1265 program->
addParamsLine(
" : if blob_radius > 0 => outside sphere");
1266 program->
addParamsLine(
" : if blob_radius < 0 => inside sphere");
1267 program->
addParamsLine(
" blob_crown <R1> <R2> <blob_radius>: 2D or 3D blob_crown");
1268 program->
addParamsLine(
" : if blob_radius > 0 => outside sphere");
1269 program->
addParamsLine(
" : if blob_radius < 0 => inside sphere");
1270 program->
addParamsLine(
" blackman : 2D or 3D Blackman mask");
1275 sprintf(tempLine,
" [ -m%c <blob_order=2>] : Order of blob",advanced);
1277 sprintf(tempLine,
" [ -a%c <blob_alpha=10.4>] : Alpha of blob",advanced);
1280 sprintf(tempLine,
" [--center%c <x0=0> <y0=0> <z0=0>]: mask center",advanced);
1374 if (
R1 < 0 &&
R2 < 0)
1380 else if (
R1 > 0 &&
R2 > 0)
1396 if (
R1 < 0 &&
H < 0)
1402 else if (
R1 > 0 &&
H > 0)
1419 if (
R1 < 0 &&
R2 < 0 &&
H<0)
1426 else if (
R1 > 0 &&
R2 > 0 &&
H>0)
1460 if (
R1 < 0 &&
R2 < 0)
1466 else if (
R1 > 0 &&
R2 > 0)
1483 if (
R1 < 0 &&
R2 < 0)
1489 else if (
R1 > 0 &&
R2 > 0)
1503 double aux = program->
getDoubleParam(
"--mask",
"blob_circular",1);
1645 img().getImage(
imask);
1650 img().getImage(
dmask);
1714 int mode,
double th1,
double th2)
1748 if (mask ==
nullptr)
1752 A(0, 0) += m2(
k,
i,
j) * m2(
k,
i,
j);
1753 A(0, 1) += m2(
k,
i,
j);
1755 b(0) += m1(
k,
i,
j) * m2(
k,
i,
j);
1756 b(1) += m1(
k,
i,
j);
1764 if ((*mask)(
k,
i,
j))
1766 A(0, 0) += m2(
k,
i,
j) * m2(
k,
i,
j);
1767 A(0, 1) += m2(
k,
i,
j);
1769 b(0) += m1(
k,
i,
j) * m2(
k,
i,
j);
1770 b(1) += m1(
k,
i,
j);
1785 each_image_produces_an_output =
true;
1786 save_metadata_stack =
true;
1787 keep_input_columns =
true;
1791 addUsageLine(
"Create or Apply a mask. Count pixels/voxels within a mask");
1793 addUsageLine(
"+You do not need to give the dimensions of the mask but you simply provide ");
1794 addUsageLine(
"+an example of image/volume you are going to apply the mask to, then the dimensions ");
1795 addUsageLine(
"+are taken from this file and the mask is created. In the creation of the mask, ");
1796 addUsageLine(
"+a file with the mask is written to disk but it is not applied to the input file.");
1798 addUsageLine(
"+You can generate blank images/volumes with the size of the sample one if you do not ");
1799 addUsageLine(
"+supply any mask type.You may also apply masks without having to generate the corresponding");
1800 addUsageLine(
"+files (but you also can save them)");
1802 addUsageLine(
"+This utility also allows you to count the number of pixels/voxels in an image/volume");
1803 addUsageLine(
"+which are inside a given mask and whose value is below|above or both some threshold.");
1805 addUsageLine(
"+See [[http://xmipp.cnb.csic.es/twiki/bin/view/Xmipp/Transform_mask_v3][here]] for more information about the program.");
1807 addExampleLine(
"Sample at circular mask inside radius 72:",
false);
1808 addExampleLine(
"xmipp_transform_mask -i reference.vol -o output_volume.vol --mask circular -72");
1809 addExampleLine(
"As above but save mask:",
false);
1810 addExampleLine(
"xmipp_transform_mask -i reference.vol --create_mask output_mask.vol --mask circular -25");
1811 addExampleLine(
"Mask and overwrite a selection file:",
false);
1812 addExampleLine(
"xmipp_transform_mask -i t7_10.sel --mask circular -72");
1813 addExampleLine(
"Mask using rectangular mask:",
false);
1814 addExampleLine(
"xmipp_transform_mask -i singleImage.spi -o salida20.spi --mask rectangular -10 -10");
1816 addParamsLine(
" [--create_mask <output_mask_file>] : Don't apply and save mask");
1817 addParamsLine(
" [--count_above <th>] : Voxels within mask >= th");
1818 addParamsLine(
" [--count_below <th>] : Voxels within mask <= th");
1819 addParamsLine(
" [--substitute <val=\"0\">] : Value outside the mask: userProvidedValue|min|max|avg");
1827 mask.readParams(
this);
1829 count_above = checkParam(
"--count_above");
1831 th_above = getDoubleParam(
"-count_above");
1832 count_below = checkParam(
"--count_below");
1834 th_below = getDoubleParam(
"--count_below");
1835 create_mask = checkParam(
"--create_mask");
1837 fn_mask = getParam(
"--create_mask");
1839 str_subs_val = getParam(
"--substitute");
1840 count = count_below || count_above;
1847 if (create_mask && input_is_stack)
1862 static size_t imageCount = 0;
1866 image().setXmippOrigin();
1869 if (
ZSIZE(image()) > 1)
1873 if (mask.x0 + mask.y0 != 0.)
1879 mask.generate_mask(image());
1884 if (str_subs_val==
"min")
1885 subs_val=image().computeMin();
1886 else if (str_subs_val==
"max")
1887 subs_val=image().computeMax();
1888 else if (str_subs_val==
"avg")
1889 subs_val=image().computeAvg();
1893 mask.apply_mask(image(), image(), subs_val, apply_geo);
1895 image.
write(fnImgOut);
1906 std::string elem_type=
"pixels";
1907 if (
ZSIZE(image())>1)
1909 if (count_above && !count_below)
1912 <<
" number of " << elem_type <<
" above " << th_above;
1916 else if (count_below && !count_above)
1919 <<
" number of " << elem_type <<
" below " << th_below;
1923 else if (count_below && count_above)
1926 <<
" number of " << elem_type <<
" above " << th_above
1927 <<
" and below " << th_below <<
" = ";
1929 image(),th_above,th_below);
1931 std::cout <<
" = " << count << std::endl;
1934 std::cerr <<
"Cannot count pixels with a continuous mask\n";
1937 if (imageCount % 25 == 0 && !count)
Just to locate unclassified errors.
void SeparableSincKaiserMask2D(MultidimArray< double > &mask, double omega, double delta, double Deltaw)
#define count_with_mask_between(mask, m, th1, th2)
void BinaryConeMask(MultidimArray< int > &mask, double theta, int mode, bool centerOrigin)
#define A2D_ELEM(v, i, j)
double alpha
Smoothness parameter.
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
Case or algorithm not implemented yet.
void BlobCircularMask(MultidimArray< double > &mask, double r1, blobtype blob, int mode, double x0, double y0, double z0)
Matrix2D< double > mask_geo
double getDoubleParam(const char *param, int arg=0)
void BinaryCrownMask(MultidimArray< int > &mask, double R1, double R2, int mode, double x0, double y0, double z0)
#define REPORT_ERROR(nerr, ErrormMsg)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
void BinaryDWTSphericalMask3D(MultidimArray< int > &mask, double radius, int smin, int smax, const std::string &quadrant)
void resizeNoCopy(const MultidimArray< T1 > &v)
No exist requested object.
void BinaryWedgeMask(MultidimArray< int > &mask, double theta0, double thetaF, const Matrix2D< double > &A, bool centerOrigin)
double beta(const double a, const double b)
Just for debugging, situation that can't happens.
void sqrt(Image< double > &op)
#define BINARY_CROWN_MASK
void BinaryCircularMask(MultidimArray< int > &mask, double radius, int mode, double x0, double y0, double z0)
#define RAISED_COSINE_MASK
#define BINARY_CYLINDER_MASK
void SincMask(MultidimArray< double > &mask, double omega, int mode, double x0, double y0, double z0)
#define DIRECT_A2D_ELEM(v, i, j)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define BINARY_FRAME_MASK
void inv(Matrix2D< T > &result) const
void abs(Image< double > &op)
void apply_geo_cont_2D_mask(MultidimArray< double > &mask, const Matrix2D< double > &A)
String integerToString(int I, int _width, char fill_with)
int paremeterPosition(int argc, const char **argv, const char *param)
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams ¶ms=DefaultApplyGeoParams)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
static void defineParams(XmippProgram *program, int allowed_data_types=ALL_KINDS, const char *prefix=nullptr, const char *comment=nullptr, bool moreOptions=false)
#define MAT_ELEM(m, i, j)
#define A3D_ELEM(V, k, i, j)
__device__ float bessi0(float x)
void read(int argc, const char **argv)
void mask3D_6neig(MultidimArray< int > &mask, int value, int center)
MultidimArray< double > dmask
#define RAISED_CROWN_MASK
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
constexpr int COUNT_BETWEEN
const char * getParameter(int argc, const char **argv, const char *param, const char *option)
const char * getParam(const char *param, int arg=0)
Mask(int _allowed_data_type=ALL_KINDS)
float textToFloat(const char *str)
Incorrect argument received.
#define XMIPP_EQUAL_ACCURACY
void BlackmanMask(MultidimArray< double > &mask, int mode, double x0, double y0, double z0)
#define DWTSPHERICALMASK_BLOCK(s, quadrant)
void progress_bar(long rlen)
#define BINARY_DWT_SPHERICAL_MASK
void BlobCrownMask(MultidimArray< double > &mask, double r1, double r2, blobtype blob, int mode, double x0, double y0, double z0)
void mask2D_8neig(MultidimArray< int > &mask, int value1, int value2, int center)
void BinaryDWTCircularMask2D(MultidimArray< int > &mask, double radius, int smin, int smax, const std::string &quadrant)
void readParams(XmippProgram *program)
#define count_with_mask_below(mask, m, th)
void GaussianMask(MultidimArray< double > &mask, double sigma, int mode, double x0, double y0, double z0)
void log10(Image< double > &op)
String stringToString(const String &str, size_t _width)
#define BINARY_DWT_CIRCULAR_MASK
void BinaryCylinderMask(MultidimArray< int > &mask, double R, double H, int mode, double x0, double y0, double z0)
void SincBlackmanMask(MultidimArray< double > &mask, double omega, double power_percentage, double x0, double y0, double z0)
#define BLOB_CIRCULAR_MASK
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
void RaisedCrownMask(MultidimArray< double > &mask, double r1, double r2, double pix_width, int mode, double x0, double y0, double z0)
void apply_geo_binary_2D_mask(MultidimArray< int > &mask, const Matrix2D< double > &A)
#define DWTCIRCULAR2D_BLOCK(s, quadrant)
void rangeAdjust_within_mask(const MultidimArray< double > *mask, const MultidimArray< double > &m1, MultidimArray< double > &m2)
void generate_mask(bool apply_geo=false)
void BinaryTubeMask(MultidimArray< int > &mask, double R1, double R2, double H, int mode, double x0, double y0, double z0)
void typeCast(const Matrix1D< T1 > &v1, Matrix1D< T2 > &v2)
#define BINARY_CIRCULAR_MASK
#define FIRST_XMIPP_INDEX(size)
int order
Derivation order and Bessel function order.
int textToInteger(const char *str)
int count_with_mask(const MultidimArray< int > &mask, const MultidimArray< std::complex< double > > &m, int mode, double th1, double th2)
constexpr int COUNT_BELOW
constexpr int OUTSIDE_MASK
void write_mask(const FileName &fn)
void getTransformationMatrix(Matrix2D< double > &A, bool only_apply_shifts=false, const size_t n=0)
MultidimArray< int > imask
void KaiserMask(MultidimArray< double > &mask, double delta, double Deltaw)
#define SPEED_UP_tempsInt
void mask3D_18neig(MultidimArray< int > &mask, int value1, int value2, int center)
void initZeros(const MultidimArray< T1 > &op)
#define blob_val(r, blob)
void mask3D_26neig(MultidimArray< int > &mask, int value1, int value2, int value3, int center)
#define LAST_XMIPP_INDEX(size)
#define FOR_ALL_ELEMENTS_IN_COMMON_IN_ARRAY3D(V1, V2)
constexpr int COUNT_ABOVE
void mask2D_4neig(MultidimArray< int > &mask, int value, int center)
void RaisedCosineMask(MultidimArray< double > &mask, double r1, double r2, int mode, double x0, double y0, double z0)
int getIntParam(const char *param, int arg=0)
#define BINARY_WEDGE_MASK
Incorrect value received.
double radius
Spatial radius in Universal System units.
int readMapped(const FileName &name, size_t select_img=ALL_IMAGES, int mode=WRITE_READONLY)
#define intWRAP(x, x0, xF)
void addParamsLine(const String &line)
void BinaryFrameMask(MultidimArray< int > &mask, int Xrect, int Yrect, int Zrect, int mode, double x0, double y0, double z0)
void SincKaiserMask(MultidimArray< double > &mask, double omega, double delta, double Deltaw)
#define count_with_mask_above(mask, m, th)