#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static 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. References NAME. 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 7756 of file processor.cpp. References EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, LOGERR, and EMAN::EMData::update(). 07757 { 07758 if (!image) { 07759 return; 07760 } 07761 07762 int nz = image->get_zsize(); 07763 if (nz > 1) { 07764 LOGERR("%s Processor doesn't support 3D model", get_name().c_str()); 07765 throw ImageDimensionException("3D model not supported"); 07766 } 07767 07768 int nsam = image->get_xsize(); 07769 int nrow = image->get_ysize(); 07770 int n1 = nsam / 2; 07771 double sx1 = double(n1)*double(nsam+1); 07772 if ( nsam % 2 == 1 ) 07773 sx1 += 1 + n1; 07774 sx1 *= nrow; 07775 int n2 = nrow / 2; 07776 double sx2 = double(n2)*double(nrow+1); 07777 if ( nrow % 2 == 1 ) 07778 sx2 += 1 + n2; 07779 sx2 *= nsam; 07780 float *data = image->get_data(); 07781 float *row = NULL; // handy pointer for values in a specific row of the data 07782 // statistical sums 07783 double syx1 = 0, syx2 = 0, sy = 0, sx1q = 0, sx2q = 0, syq = 0; 07784 for (int j=1; j <= nrow; j++) { 07785 row = data + (j-1)*nsam - 1; // "-1" so that we can start counting at 1 07786 for (int i=1; i<=nsam; i++) { 07787 syx1 += row[i]*i; 07788 syx2 += row[i]*j; 07789 sy += row[i]; 07790 sx1q += i*i; 07791 sx2q += j*j; 07792 syq += row[i]*double(row[i]); 07793 } 07794 } 07795 // least-squares 07796 float dn = float(nsam)*float(nrow); 07797 double qyx1 = syx1 - sx1*sy / dn; 07798 double qyx2 = syx2 - sx2*sy / dn; 07799 double qx1x2 = 0.0; 07800 double qx1 = sx1q - sx1*sx1 / dn; 07801 double qx2 = sx2q - sx2*sx2 / dn; 07802 double qy = syq - sy*sy / dn; 07803 double c = qx1*qx2 - qx1x2*qx1x2; 07804 if ( c > FLT_EPSILON ) { 07805 double b1 = (qyx1*qx2 - qyx2*qx1x2) / c; 07806 double b2 = (qyx2*qx1 - qyx1*qx1x2) / c; 07807 double a = (sy - b1*sx1 - b2*sx2) / dn; 07808 double d = a + b1 + b2; 07809 for (int i=1; i<=nrow; i++) { 07810 qy = d; 07811 row = data + (i-1)*nsam - 1; 07812 for (int k=1; k<=nsam; k++) { 07813 row[k] -= static_cast<float>(qy); 07814 qy += b1; 07815 } 07816 d += b2; 07817 } 07818 } // image not altered if c is zero 07819 07820 image->update(); 07821 }
|
|
Definition at line 3708 of file processor.h. Referenced by get_name(). |