#include <processor.h>
Inheritance diagram for EMAN::MeanZeroEdgeProcessor:
Public Member Functions | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
string | get_name () const |
Get the processor's name. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "mask.dampedzeroedgefill" |
Definition at line 3865 of file processor.h.
string EMAN::MeanZeroEdgeProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 3880 of file processor.h.
03881 { 03882 return "Fill zeroes at edges with nearest horizontal/vertical value damped towards Mean2."; 03883 }
string EMAN::MeanZeroEdgeProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 3870 of file processor.h.
References NAME.
03871 { 03872 return NAME; 03873 }
static Processor* EMAN::MeanZeroEdgeProcessor::NEW | ( | ) | [inline, static] |
Definition at line 3875 of file processor.h.
03876 { 03877 return new MeanZeroEdgeProcessor(); 03878 }
void MeanZeroEdgeProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 3243 of file processor.cpp.
References EMAN::Dict::get(), EMAN::EMData::get_attr_dict(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, LOGWARN, EMAN::EMData::update(), and v.
03244 { 03245 if (!image) { 03246 LOGWARN("NULL Image"); 03247 return; 03248 } 03249 if (image->get_zsize() > 1) { 03250 LOGERR("MeanZeroEdgeProcessor doesn't support 3D model"); 03251 throw ImageDimensionException("3D model not supported"); 03252 } 03253 03254 int nx = image->get_xsize(); 03255 int ny = image->get_ysize(); 03256 Dict dict = image->get_attr_dict(); 03257 float mean_nonzero = dict.get("mean_nonzero"); 03258 03259 float *d = image->get_data(); 03260 int i = 0; 03261 int j = 0; 03262 03263 for (j = 0; j < ny; j++) { 03264 for (i = 0; i < nx - 1; i++) { 03265 if (d[i + j * nx] != 0) { 03266 break; 03267 } 03268 } 03269 03270 if (i == nx - 1) { 03271 i = -1; 03272 } 03273 03274 float v = d[i + j * nx] - mean_nonzero; 03275 03276 while (i >= 0) { 03277 v *= 0.9f; 03278 d[i + j * nx] = v + mean_nonzero; 03279 i--; 03280 } 03281 03282 03283 for (i = nx - 1; i > 0; i--) { 03284 if (d[i + j * nx] != 0) { 03285 break; 03286 } 03287 } 03288 03289 if (i == 0) { 03290 i = nx; 03291 } 03292 03293 v = d[i + j * nx] - mean_nonzero; 03294 03295 while (i < nx) { 03296 v *= .9f; 03297 d[i + j * nx] = v + mean_nonzero; 03298 i++; 03299 } 03300 } 03301 03302 03303 for (i = 0; i < nx; i++) { 03304 for (j = 0; j < ny; j++) { 03305 if (d[i + j * nx] != 0) 03306 break; 03307 } 03308 03309 float v = d[i + j * nx] - mean_nonzero; 03310 03311 while (j >= 0) { 03312 v *= .9f; 03313 d[i + j * nx] = v + mean_nonzero; 03314 j--; 03315 } 03316 03317 for (j = ny - 1; j > 0; j--) { 03318 if (d[i + j * nx] != 0) 03319 break; 03320 } 03321 03322 v = d[i + j * nx] - mean_nonzero; 03323 03324 while (j < ny) { 03325 v *= .9f; 03326 d[i + j * nx] = v + mean_nonzero; 03327 j++; 03328 } 03329 } 03330 03331 image->update(); 03332 }
const string MeanZeroEdgeProcessor::NAME = "mask.dampedzeroedgefill" [static] |