To compare 'image' with another image passed in through its parameters.
An optional transformation may be used to transform the 2 images.
290 if (zeromask) with = withorig->process(
"normalize.toimage",
Dict(
"to",image));
291 else with = withorig->process(
"normalize.toimage",
Dict(
"to",image,
"ignore_zero",0));
292 with->set_attr(
"deleteme",1);
293 if ((
float)(with->get_attr(
"norm_mult"))<=0) {
299 const float *
const y_data = with->get_const_data();
300 const float *
const x_data = image->get_const_data();
303 if(image->is_complex() && with->is_complex()) {
305 int nx = with->get_xsize();
306 int ny = with->get_ysize();
307 int nz = with->get_zsize();
308 nx = (nx - 2 + with->is_fftodd());
309 int lsd2 = (nx + 2 - nx%2) ;
311 int ixb = 2*((nx+1)%2);
316 for (
int iz = 0; iz <= nz-1; iz++) {
318 for (
int iy = 0; iy <= ny-1; iy++) {
319 for (
int ix = 2; ix <= lsd2 - 1 - ixb; ix++) {
320 size_t ii = ix + (iy + iz * ny)* lsd2;
321 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
324 for (
int iy = 1; iy <= ny/2-1 + iyb; iy++) {
325 size_t ii = (iy + iz * ny)* lsd2;
326 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
327 part += (x_data[ii+1] - y_data[ii+1])*
double(x_data[ii+1] - y_data[ii+1]);
330 for (
int iy = 1; iy <= ny/2-1 + iyb; iy++) {
331 size_t ii = lsd2 - 2 + (iy + iz * ny)* lsd2;
332 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
333 part += (x_data[ii+1] - y_data[ii+1])*
double(x_data[ii+1] - y_data[ii+1]);
338 part += (x_data[0] - y_data[0])*
double(x_data[0] - y_data[0]);
340 int ii = (ny/2 + iz * ny)* lsd2;
341 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
344 int ii = lsd2 - 2 + (0 + iz * ny)* lsd2;
345 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
347 int ii = lsd2 - 2 +(ny/2 + iz * ny)* lsd2;
348 part += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
353 n = (float)nx*(
float)ny*(float)nz*(
float)nx*(float)ny*(
float)nz;
357 int ny2 = ny/2;
int nz2 = nz/2;
358 for (
int iz = 0; iz <= nz-1; iz++) {
359 if(iz>nz2) kz=iz-nz;
else kz=iz;
360 for (
int iy = 0; iy <= ny-1; iy++) {
361 if(iy>ny2) ky=iy-ny;
else ky=iy;
362 for (
int ix = 0; ix <= lsd2-1; ix++) {
364 if(ix>0 || (kz>=0 && (ky>=0 || kz!=0))) {
365 size_t ii = ix + (iy + iz * ny)* (
size_t)lsd2;
366 result += (x_data[ii] - y_data[ii])*
double(x_data[ii] - y_data[ii]);
371 n = ((float)nx*(
float)ny*(float)nz*(
float)nx*(float)ny*(
float)nz)/2.0f;
374 size_t totsize = (size_t)image->get_xsize()*image->get_ysize()*image->get_zsize();
378 const float *
const dm = mask->get_const_data();
379 for (
size_t i = 0; i < totsize; i++) {
381 double temp = x_data[i]- y_data[i];
389 for (
size_t i = 0; i < totsize; i++) {
390 if (x_data[i]==0 || y_data[i]==0)
continue;
391 double temp = x_data[i]- y_data[i];
398 for (
size_t i = 0; i < totsize; i++) {
399 double temp = x_data[i]- y_data[i];
408 if (with->has_attr(
"deleteme"))
delete with;
409 float ret = (float)result;
void validate_input_args(const EMData *image, const EMData *with) const
Dict is a dictionary to store <string, EMObject> pair.
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
EMData stores an image's data and defines core image processing routines.
static int goodf(const float *p_f)
Check whether a number is a good float.