#include <processor.h>
Inheritance diagram for EMAN::AutoMask3DProcessor:


Public Member Functions | |
| virtual void | process_inplace (EMData *image) |
| To process an image in-place. | |
| virtual string | get_name () const |
| Get the processor's name. | |
| virtual TypeDict | get_param_types () const |
| Get processor parameter information in a dictionary. | |
| virtual string | get_desc () const |
| Get the descrition of this specific processor. | |
Static Public Member Functions | |
| Processor * | NEW () |
| void | search_nearby (float *dat, float *dat2, int nx, int ny, int nz, float thr) |
| void | fill_nearby (float *dat2, int nx, int ny, int nz) |
Static Public Attributes | |
| const string | NAME = "mask.auto3d.thresh" |
| threshold1 | ||
| threshold2 |
Definition at line 4901 of file processor.h.
|
||||||||||||||||||||
|
Definition at line 6222 of file processor.cpp. References Assert, nx, and ny. Referenced by process_inplace(). 06223 {
06224 Assert(dat2 != 0);
06225 Assert(nx > 0);
06226 Assert(ny > 0);
06227 Assert(nz >= 0);
06228
06229 int nxy = nx * ny;
06230 size_t idx;
06231 for (int i = 0; i < nx; ++i) {
06232 for (int j = 0; j < ny; ++j) {
06233 int j2 = j * nx + i;
06234 int k0 = 0;
06235 for (int k = 0; k < nz; ++k) {
06236 idx = j2 + (size_t)k * nxy;
06237 if (dat2[idx]) {
06238 k0 = k;
06239 break;
06240 }
06241 }
06242
06243 if (k0 != nz) {
06244 int k1 = nz - 1;
06245 for (int k = nz - 1; k >= 0; --k) {
06246 idx = j2 + (size_t)k * nxy;
06247 if (dat2[idx]) {
06248 k1 = k;
06249 break;
06250 }
06251 }
06252
06253 for (int k = k0 + 1; k < k1; ++k) {
06254 idx = j2 + (size_t)k * nxy;
06255 dat2[idx] = 1.0f;
06256 }
06257 }
06258 }
06259 }
06260
06261 for (int i = 0; i < nx; ++i) {
06262 for (int j = 0; j < nz; ++j) {
06263 size_t j2 = (size_t)j * nxy + i;
06264 int k0 = 0;
06265 for (int k = 0; k < ny; ++k) {
06266 idx = (size_t)k * nx + j2;
06267 if (dat2[idx]) {
06268 k0 = k;
06269 break;
06270 }
06271 }
06272
06273 if (k0 != ny) {
06274 int k1 = ny - 1;
06275 for (int k = ny - 1; k >= 0; --k) {
06276 idx = (size_t)k * nx + j2;
06277 if (dat2[idx]) {
06278 k1 = k;
06279 break;
06280 }
06281 }
06282
06283 for (int k = k0 + 1; k < k1; ++k) {
06284 idx = (size_t)k * nx + j2;
06285 dat2[idx] = 1.0f;
06286 }
06287 }
06288 }
06289 }
06290
06291 for (int i = 0; i < ny; ++i) {
06292 for (int j = 0; j < nz; ++j) {
06293 size_t j2 = i * nx + (size_t)j * nxy;
06294 int k0 = 0;
06295 for (int k = 0; k < nx; ++k) {
06296 if (dat2[k + j2]) {
06297 k0 = k;
06298 break;
06299 }
06300 }
06301 if (k0 != nx) {
06302 int k1 = nx - 1;
06303 for (int k = nx - 1; k >= 0; --k) {
06304 if (dat2[k + j2]) {
06305 k1 = k;
06306 break;
06307 }
06308 }
06309
06310 for (int k = k0 + 1; k < k1; ++k) {
06311 dat2[k + j2] = 1.0f;
06312 }
06313 }
06314 }
06315 }
06316
06317 }
|
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 4924 of file processor.h. 04925 {
04926 return "Tries to mask out only interesting density";
04927 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4906 of file processor.h. 04907 {
04908 return NAME;
04909 }
|
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 4916 of file processor.h. References EMAN::TypeDict::put(). 04917 {
04918 TypeDict d;
04919 d.put("threshold1", EMObject::FLOAT);
04920 d.put("threshold2", EMObject::FLOAT);
04921 return d;
04922 }
|
|
|
Definition at line 4911 of file processor.h. 04912 {
04913 return new AutoMask3DProcessor();
04914 }
|
|
|
To process an image in-place. For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
Implements EMAN::Processor. Definition at line 6319 of file processor.cpp. References fill_nearby(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), LOGWARN, EMAN::EMData::mult(), nx, ny, search_nearby(), EMAN::EMData::set_size(), t, EMAN::EMData::update(), and EMAN::EMData::write_image(). 06320 {
06321 if (!image) {
06322 LOGWARN("NULL Image");
06323 return;
06324 }
06325
06326 int nx = image->get_xsize();
06327 int ny = image->get_ysize();
06328 int nz = image->get_zsize();
06329
06330 EMData *amask = new EMData();
06331 amask->set_size(nx, ny, nz);
06332
06333 float sig = 0;
06334 float mean = 0;
06335
06336 if (params.has_key("threshold1") && params.has_key("threshold2")) {
06337 sig = image->get_attr("sigma");
06338 mean = image->get_attr("mean");
06339 }
06340
06341 float *dat = image->get_data();
06342 float *dat2 = amask->get_data();
06343
06344 float t = 0;
06345 if (params.has_key("threshold1")) {
06346 t = params["threshold1"];
06347 }
06348 else {
06349 t = mean + sig * 2.5f;
06350 }
06351
06352 size_t l = 0;
06353 for (int k = 0; k < nz; ++k) {
06354 for (int j = 0; j < ny; ++j) {
06355 for (int i = 0; i < nx; ++i) {
06356 if (dat[l] > t) {
06357 dat2[l] = 1.0f;
06358 }
06359 ++l;
06360 }
06361 }
06362 }
06363
06364
06365 if (params.has_key("threshold2")) {
06366 t = params["threshold2"];
06367 }
06368 else {
06369 t = mean + sig * 0.5f;
06370 }
06371
06372 search_nearby(dat, dat2, nx, ny, nz, t);
06373
06374 int nxy = nx * ny;
06375
06376 for (int k = 1; k < nz - 1; ++k) {
06377 for (int j = 1; j < ny - 1; ++j) {
06378 size_t l = j * nx + (size_t)k * nxy + 1;
06379 for (int i = 1; i < nx - 1; ++i, ++l) {
06380 if (dat2[l - 1] == 1.0f || dat2[l + 1] == 1.0f ||
06381 dat2[l - nx] == 1.0f || dat2[l + nx] == 1.0f ||
06382 dat2[l - nxy] == 1.0f || dat2[l + nxy] == 1.0f) {
06383 dat2[l] = 2.0f;
06384 }
06385 }
06386 }
06387 }
06388
06389 size_t size = (size_t)nx * ny * nz;
06390 for (size_t i = 0; i < size; ++i) {
06391 if (dat2[i] == 2.0f) {
06392 dat2[i] = 1.0f;
06393 }
06394 }
06395
06396 fill_nearby(dat2, nx, ny, nz);
06397
06398 image->update();
06399 amask->update();
06400
06401 image->mult(*amask);
06402 amask->write_image("mask.mrc", 0, EMUtil::IMAGE_MRC);
06403 if( amask )
06404 {
06405 delete amask;
06406 amask = 0;
06407 }
06408 }
|
|
||||||||||||||||||||||||||||
|
Definition at line 6190 of file processor.cpp. References Assert, nx, and ny. Referenced by process_inplace(). 06191 {
06192 Assert(dat != 0);
06193 Assert(dat2 != 0);
06194 Assert(nx > 0);
06195 Assert(ny > 0);
06196
06197 bool done = false;
06198 int nxy = nx * ny;
06199
06200 while (!done) {
06201 done = true;
06202 for (int k = 1; k < nz - 1; k++) {
06203 size_t k2 = (size_t)k * nxy;
06204 for (int j = 1; j < ny - 1; j++) {
06205 size_t l = j * nx + k2 + 1;
06206
06207 for (int i = 1; i < nx - 1; i++) {
06208 if (dat[l] >= threshold || dat2[l]) {
06209 if (dat2[l - 1] || dat2[l + 1] ||
06210 dat2[l - nx] || dat2[l + nx] || dat2[l - nxy] || dat2[l + nxy]) {
06211 dat2[l] = 1.0f;
06212 done = false;
06213 }
06214 }
06215 ++l;
06216 }
06217 }
06218 }
06219 }
06220 }
|
|
|
Definition at line 167 of file processor.cpp. |
1.3.9.1