#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 3825 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 3840 of file processor.h.
03841 { 03842 return "Fill zeroes at edges with nearest horizontal/vertical value damped towards Mean2."; 03843 }
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 3830 of file processor.h.
References NAME.
03831 { 03832 return NAME; 03833 }
static Processor* EMAN::MeanZeroEdgeProcessor::NEW | ( | ) | [inline, static] |
Definition at line 3835 of file processor.h.
03836 { 03837 return new MeanZeroEdgeProcessor(); 03838 }
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 3136 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.
03137 { 03138 if (!image) { 03139 LOGWARN("NULL Image"); 03140 return; 03141 } 03142 if (image->get_zsize() > 1) { 03143 LOGERR("MeanZeroEdgeProcessor doesn't support 3D model"); 03144 throw ImageDimensionException("3D model not supported"); 03145 } 03146 03147 int nx = image->get_xsize(); 03148 int ny = image->get_ysize(); 03149 Dict dict = image->get_attr_dict(); 03150 float mean_nonzero = dict.get("mean_nonzero"); 03151 03152 float *d = image->get_data(); 03153 int i = 0; 03154 int j = 0; 03155 03156 for (j = 0; j < ny; j++) { 03157 for (i = 0; i < nx - 1; i++) { 03158 if (d[i + j * nx] != 0) { 03159 break; 03160 } 03161 } 03162 03163 if (i == nx - 1) { 03164 i = -1; 03165 } 03166 03167 float v = d[i + j * nx] - mean_nonzero; 03168 03169 while (i >= 0) { 03170 v *= 0.9f; 03171 d[i + j * nx] = v + mean_nonzero; 03172 i--; 03173 } 03174 03175 03176 for (i = nx - 1; i > 0; i--) { 03177 if (d[i + j * nx] != 0) { 03178 break; 03179 } 03180 } 03181 03182 if (i == 0) { 03183 i = nx; 03184 } 03185 03186 v = d[i + j * nx] - mean_nonzero; 03187 03188 while (i < nx) { 03189 v *= .9f; 03190 d[i + j * nx] = v + mean_nonzero; 03191 i++; 03192 } 03193 } 03194 03195 03196 for (i = 0; i < nx; i++) { 03197 for (j = 0; j < ny; j++) { 03198 if (d[i + j * nx] != 0) 03199 break; 03200 } 03201 03202 float v = d[i + j * nx] - mean_nonzero; 03203 03204 while (j >= 0) { 03205 v *= .9f; 03206 d[i + j * nx] = v + mean_nonzero; 03207 j--; 03208 } 03209 03210 for (j = ny - 1; j > 0; j--) { 03211 if (d[i + j * nx] != 0) 03212 break; 03213 } 03214 03215 v = d[i + j * nx] - mean_nonzero; 03216 03217 while (j < ny) { 03218 v *= .9f; 03219 d[i + j * nx] = v + mean_nonzero; 03220 j++; 03221 } 03222 } 03223 03224 image->update(); 03225 }
const string MeanZeroEdgeProcessor::NAME = "mask.dampedzeroedgefill" [static] |