#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 3859 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 3874 of file processor.h.
03875 { 03876 return "Fill zeroes at edges with nearest horizontal/vertical value damped towards Mean2."; 03877 }
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 3864 of file processor.h.
References NAME.
03865 { 03866 return NAME; 03867 }
static Processor* EMAN::MeanZeroEdgeProcessor::NEW | ( | ) | [inline, static] |
Definition at line 3869 of file processor.h.
03870 { 03871 return new MeanZeroEdgeProcessor(); 03872 }
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 3230 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.
03231 { 03232 if (!image) { 03233 LOGWARN("NULL Image"); 03234 return; 03235 } 03236 if (image->get_zsize() > 1) { 03237 LOGERR("MeanZeroEdgeProcessor doesn't support 3D model"); 03238 throw ImageDimensionException("3D model not supported"); 03239 } 03240 03241 int nx = image->get_xsize(); 03242 int ny = image->get_ysize(); 03243 Dict dict = image->get_attr_dict(); 03244 float mean_nonzero = dict.get("mean_nonzero"); 03245 03246 float *d = image->get_data(); 03247 int i = 0; 03248 int j = 0; 03249 03250 for (j = 0; j < ny; j++) { 03251 for (i = 0; i < nx - 1; i++) { 03252 if (d[i + j * nx] != 0) { 03253 break; 03254 } 03255 } 03256 03257 if (i == nx - 1) { 03258 i = -1; 03259 } 03260 03261 float v = d[i + j * nx] - mean_nonzero; 03262 03263 while (i >= 0) { 03264 v *= 0.9f; 03265 d[i + j * nx] = v + mean_nonzero; 03266 i--; 03267 } 03268 03269 03270 for (i = nx - 1; i > 0; i--) { 03271 if (d[i + j * nx] != 0) { 03272 break; 03273 } 03274 } 03275 03276 if (i == 0) { 03277 i = nx; 03278 } 03279 03280 v = d[i + j * nx] - mean_nonzero; 03281 03282 while (i < nx) { 03283 v *= .9f; 03284 d[i + j * nx] = v + mean_nonzero; 03285 i++; 03286 } 03287 } 03288 03289 03290 for (i = 0; i < nx; i++) { 03291 for (j = 0; j < ny; j++) { 03292 if (d[i + j * nx] != 0) 03293 break; 03294 } 03295 03296 float v = d[i + j * nx] - mean_nonzero; 03297 03298 while (j >= 0) { 03299 v *= .9f; 03300 d[i + j * nx] = v + mean_nonzero; 03301 j--; 03302 } 03303 03304 for (j = ny - 1; j > 0; j--) { 03305 if (d[i + j * nx] != 0) 03306 break; 03307 } 03308 03309 v = d[i + j * nx] - mean_nonzero; 03310 03311 while (j < ny) { 03312 v *= .9f; 03313 d[i + j * nx] = v + mean_nonzero; 03314 j++; 03315 } 03316 } 03317 03318 image->update(); 03319 }
const string MeanZeroEdgeProcessor::NAME = "mask.dampedzeroedgefill" [static] |