#include <processor.h>
Inheritance diagram for EMAN::RampProcessor:
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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "filter.ramp" |
A wedge-shaped overall density profile can thus be removed from the picture.
Definition at line 3767 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 3781 of file processor.h. 03782 { 03783 return "Ramp processor -- Fits a least-squares plane " 03784 "to the picture, and subtracts the plane from " 03785 "the picture. A wedge-shaped overall density " 03786 "profile can thus be removed from the picture."; 03787 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3772 of file processor.h. Referenced by process_inplace(). 03773 {
03774 return NAME;
03775 }
|
|
Definition at line 3776 of file processor.h. 03777 { 03778 return new RampProcessor(); 03779 }
|
|
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 8096 of file processor.cpp. References data, EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, and EMAN::EMData::update(). 08097 { 08098 if (!image) { 08099 return; 08100 } 08101 08102 int nz = image->get_zsize(); 08103 if (nz > 1) { 08104 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 08105 throw ImageDimensionException("3D model not supported"); 08106 } 08107 08108 int nsam = image->get_xsize(); 08109 int nrow = image->get_ysize(); 08110 int n1 = nsam / 2; 08111 double sx1 = double(n1)*double(nsam+1); 08112 if ( nsam % 2 == 1 ) 08113 sx1 += 1 + n1; 08114 sx1 *= nrow; 08115 int n2 = nrow / 2; 08116 double sx2 = double(n2)*double(nrow+1); 08117 if ( nrow % 2 == 1 ) 08118 sx2 += 1 + n2; 08119 sx2 *= nsam; 08120 float *data = image->get_data(); 08121 float *row = NULL; // handy pointer for values in a specific row of the data 08122 // statistical sums 08123 double syx1 = 0, syx2 = 0, sy = 0, sx1q = 0, sx2q = 0, syq = 0; 08124 for (int j=1; j <= nrow; j++) { 08125 row = data + (j-1)*nsam - 1; // "-1" so that we can start counting at 1 08126 for (int i=1; i<=nsam; i++) { 08127 syx1 += row[i]*i; 08128 syx2 += row[i]*j; 08129 sy += row[i]; 08130 sx1q += i*i; 08131 sx2q += j*j; 08132 syq += row[i]*double(row[i]); 08133 } 08134 } 08135 // least-squares 08136 float dn = float(nsam)*float(nrow); 08137 double qyx1 = syx1 - sx1*sy / dn; 08138 double qyx2 = syx2 - sx2*sy / dn; 08139 double qx1x2 = 0.0; 08140 double qx1 = sx1q - sx1*sx1 / dn; 08141 double qx2 = sx2q - sx2*sx2 / dn; 08142 double qy = syq - sy*sy / dn; 08143 double c = qx1*qx2 - qx1x2*qx1x2; 08144 if ( c > FLT_EPSILON ) { 08145 double b1 = (qyx1*qx2 - qyx2*qx1x2) / c; 08146 double b2 = (qyx2*qx1 - qyx1*qx1x2) / c; 08147 double a = (sy - b1*sx1 - b2*sx2) / dn; 08148 double d = a + b1 + b2; 08149 for (int i=1; i<=nrow; i++) { 08150 qy = d; 08151 row = data + (i-1)*nsam - 1; 08152 for (int k=1; k<=nsam; k++) { 08153 row[k] -= static_cast<float>(qy); 08154 qy += b1; 08155 } 08156 d += b2; 08157 } 08158 } // image not altered if c is zero 08159 08160 image->update(); 08161 }
|
|
Definition at line 132 of file processor.cpp. |