#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 3686 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 3700 of file processor.h. 03701 { 03702 return "Ramp processor -- Fits a least-squares plane " 03703 "to the picture, and subtracts the plane from " 03704 "the picture. A wedge-shaped overall density " 03705 "profile can thus be removed from the picture."; 03706 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 3691 of file processor.h. Referenced by process_inplace(). 03692 {
03693 return NAME;
03694 }
|
|
Definition at line 3695 of file processor.h. 03696 { 03697 return new RampProcessor(); 03698 }
|
|
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 7725 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(). 07726 { 07727 if (!image) { 07728 return; 07729 } 07730 07731 int nz = image->get_zsize(); 07732 if (nz > 1) { 07733 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 07734 throw ImageDimensionException("3D model not supported"); 07735 } 07736 07737 int nsam = image->get_xsize(); 07738 int nrow = image->get_ysize(); 07739 int n1 = nsam / 2; 07740 double sx1 = double(n1)*double(nsam+1); 07741 if ( nsam % 2 == 1 ) 07742 sx1 += 1 + n1; 07743 sx1 *= nrow; 07744 int n2 = nrow / 2; 07745 double sx2 = double(n2)*double(nrow+1); 07746 if ( nrow % 2 == 1 ) 07747 sx2 += 1 + n2; 07748 sx2 *= nsam; 07749 float *data = image->get_data(); 07750 float *row = NULL; // handy pointer for values in a specific row of the data 07751 // statistical sums 07752 double syx1 = 0, syx2 = 0, sy = 0, sx1q = 0, sx2q = 0, syq = 0; 07753 for (int j=1; j <= nrow; j++) { 07754 row = data + (j-1)*nsam - 1; // "-1" so that we can start counting at 1 07755 for (int i=1; i<=nsam; i++) { 07756 syx1 += row[i]*i; 07757 syx2 += row[i]*j; 07758 sy += row[i]; 07759 sx1q += i*i; 07760 sx2q += j*j; 07761 syq += row[i]*double(row[i]); 07762 } 07763 } 07764 // least-squares 07765 float dn = float(nsam)*float(nrow); 07766 double qyx1 = syx1 - sx1*sy / dn; 07767 double qyx2 = syx2 - sx2*sy / dn; 07768 double qx1x2 = 0.0; 07769 double qx1 = sx1q - sx1*sx1 / dn; 07770 double qx2 = sx2q - sx2*sx2 / dn; 07771 double qy = syq - sy*sy / dn; 07772 double c = qx1*qx2 - qx1x2*qx1x2; 07773 if ( c > FLT_EPSILON ) { 07774 double b1 = (qyx1*qx2 - qyx2*qx1x2) / c; 07775 double b2 = (qyx2*qx1 - qyx1*qx1x2) / c; 07776 double a = (sy - b1*sx1 - b2*sx2) / dn; 07777 double d = a + b1 + b2; 07778 for (int i=1; i<=nrow; i++) { 07779 qy = d; 07780 row = data + (i-1)*nsam - 1; 07781 for (int k=1; k<=nsam; k++) { 07782 row[k] -= static_cast<float>(qy); 07783 qy += b1; 07784 } 07785 d += b2; 07786 } 07787 } // image not altered if c is zero 07788 07789 image->update(); 07790 }
|
|
Definition at line 131 of file processor.cpp. |