37 if (srcImageHist.dim() != 2)
38 throw invalid_argument(
"pp310:setup: '" +
name() +
39 "' The input histogram is not a 2d histogram");
43 "' will calculate the autocorrelation of '" +
_hist->name() +
44 "'. Condition is '" +
_condition->name() +
"'");
58 for (
size_t row(0); row < nRows; ++row)
60 const_iterator rowStart(hist.
begin() + row*nCols);
61 const_iterator rowEnd(hist.
begin() + row*nCols + nCols);
63 for (
size_t col(0); col < nCols; ++col)
66 rotate_copy(rowStart, rowStart+col, rowEnd, row_buffer.begin());
69 transform(rowStart,rowEnd,row_buffer.begin(),row_buffer.begin(),multiplies<float>());
72 const float autocorval(accumulate(row_buffer.begin(),row_buffer.end(),0));
75 result[row*nCols + col] = autocorval;
100 std::pair<int,int> usercenter = make_pair(s.
value(
"CenterX",0).toInt(),
101 s.
value(
"CenterY",0).toInt());
102 const int maxradius(s.
value(
"MaximumRadius",0).toInt());
105 if (srcImageHist.dim() != 2)
106 throw invalid_argument(
"pp311:setup: '" +
name() +
107 "' The input histogram is not a 2d histogram");
111 _center = make_pair(xaxis.bin(usercenter.first),
112 yaxis.bin(usercenter.second));
115 if ((static_cast<int>(srcImageHist.shape().first) < _center.first + maxradius) ||
116 (_center.first - maxradius < 0) )
117 throw out_of_range(
"pp311:loadSettings: '" +
name() +
"'. Center in lab X '" +
118 toString(_center.first) +
"' and maximum radius '" +
119 toString(maxradius) +
"' do not fit in image with width '" +
120 toString(srcImageHist.shape().first) +
"'");
121 if ((static_cast<int>(srcImageHist.shape().second) < _center.second + maxradius) ||
122 (_center.second - maxradius < 0))
123 throw out_of_range(
"pp311:loadSettings: '" +
name() +
"'. Center in lab Y '" +
124 toString(_center.second) +
"' and maximum radius '" +
125 toString(maxradius) +
"' do not fit in image with height '" +
126 toString(srcImageHist.shape().second) +
"'");
132 "' will calculate the autocorrelation of '" +
_hist->name() +
133 "'. Condition is '" +
_condition->name() +
"'");
143 int ddF_y = -2 * rad;
164 const int rad,
const int x0,
const int y0,
const int nxx,
167 const int nAngles(ring.size());
170 int ddF_y = -2 * rad;
174 const int angsym2 = nAngles*2*0.125;
175 const int angsym4 = nAngles*4*0.125;
176 const int angsym6 = nAngles*6*0.125;
177 const int angsym8 = nAngles;
179 ring[angle].first= x0 + nxx*(y0+rad);
180 ring[angle].second = image[ring[angle].first];
182 ring[angle+angsym4].first= x0 + nxx*(y0 - rad);
183 ring[angle+angsym4].second = image[ring[angle+angsym4].first];
185 ring[angle+angsym2].first= x0 + rad + nxx*(y0);
186 ring[angle+angsym2].second = image[ring[angle+angsym2].first];
188 ring[angle+angsym6].first= x0 - rad + nxx*(y0);
189 ring[angle+angsym6].second = image[ring[angle+angsym6].first];
204 ring[angle].first= x0 + x + nxx*(y0 +
y);
205 ring[angle].second = image[ring[angle].first];
207 ring[angsym8-angle].first= x0 - x + nxx*(y0 +
y);
208 ring[angsym8-angle].second = image[ring[angsym8-angle].first];
210 ring[angsym4-angle].first= x0 + x + nxx*(y0 -
y);
211 ring[angsym4-angle].second = image[ring[angsym4-angle].first];
213 ring[angsym4+angle].first= x0 - x + nxx*(y0 -
y);
214 ring[angsym4+angle].second = image[ring[angsym4+angle].first];
218 ring[angsym2-angle].first= x0 + y + nxx*(y0 +
x);
219 ring[angsym2-angle].second = image[ring[angsym2-angle].first];
221 ring[angsym6+angle].first= x0 - y + nxx*(y0 +
x);
222 ring[angsym6+angle].second = image[ring[angsym6+angle].first];
224 ring[angsym2+angle].first= x0 + y + nxx*(y0 -
x);
225 ring[angsym2+angle].second = image[ring[angsym2+angle].first];
227 ring[angsym6-angle].first= x0 - y + nxx*(y0 -
x);
228 ring[angsym6-angle].second = image[ring[angsym6-angle].first];
238 const int nxx(hist.
shape().first);
241 for(
int rad=0; rad<
_maxrad; ++rad)
244 ring.resize(ringsize);
247 #pragma omp parallel for
249 for (
int d_phi_pix=0; d_phi_pix < ringsize; ++d_phi_pix)
252 for (
int ii=0; ii<ringsize; ++ii)
253 res += ring[ii].second * ring[(ii+d_phi_pix)%ringsize].second;
254 res /=
static_cast<float>(ringsize);
255 result[ring[d_phi_pix].first] = res;
storage_t::const_iterator const_iterator
a const iterator on the storage
void fillRing(const result_t &image, const int rad, const int x0, const int y0, const int nxx, ring_t &ring)
fill the ring with the pixels that belong to a certain radius around a given center ...
Event to store all LCLS Data.
virtual void createHistList(result_t::shared_pointer result)
create result list.
virtual void process(const CASSEvent &, result_t &)
process the event
std::vector< value_t > storage_t
the storage of this container
virtual void loadSettings(size_t)
load the settings of this pp
const name_t name() const
retrieve the name of this processor
file contains declaration of the CASSEvent
std::pair< int, int > _center
the used center of the image
virtual void process(const CASSEvent &, result_t &)
process the event
an axis of a more than 0 dimensional container
int _maxrad
the used maximum radius
int getCircleLength(const int rad)
retrieve the length of the ring for a given radius
static void add(Level level, const std::string &line)
add a string to the log
const_iterator begin() const
retrieve a iterator for read access to beginning
fromStdString(const std::string &str)
base class for processors.
pp311(const name_t &)
constructor
shared_pointer setupDependency(const std::string &depVarName, const name_t &name="")
setup the dependecy.
const axis_t & axis() const
read access to the axis
virtual void loadSettings(size_t)
load the settings of this pp
pp310(const name_t &)
constructor
QReadWriteLock lock
lock for locking operations on the data of the container
shared_pointer _hist
pp containing histogram to calculate the autocorrelation for
std::vector< std::pair< int, result_t::value_t > > ring_t
define a ring that knows its position in the original image and the value at that position ...
std::string toString(const Type &t)
convert any type to a string
value(const QString &key, const QVariant &defaultValue=QVariant()
shared_pointer _hist
pp containing histogram to calculate the autocorrelation for
void setupGeneral()
general setup of the processor
file contains specialized class that do the settings for cass
shared_pointer _condition
pointer to the processor that will contain the condition
shape_t shape() const
return the shape of the result
bool setupCondition(bool defaultConditionType=true)
setup the condition.
std::string name_t
define the name type
contains a logger for cass
containing the class to calculate the autocorrelation of a 2d histogram
beginGroup(const QString &prefix)