void rotate_(T *out, const T *in, const float theta, const af::dim4 &odims, const af::dim4 &idims, const af::dim4 &ostrides, const af::dim4 &istrides) { dim_t nimages = idims[2]; void (*t_fn)(T *, const T *, const float *, const af::dim4 &, const af::dim4 &, const af::dim4 &, const dim_t, const dim_t, const dim_t, const dim_t); const float c = cos(-theta), s = sin(-theta); float tx, ty; { const float nx = 0.5 * (idims[0] - 1); const float ny = 0.5 * (idims[1] - 1); const float mx = 0.5 * (odims[0] - 1); const float my = 0.5 * (odims[1] - 1); const float sx = (mx * c + my *-s); const float sy = (mx * s + my * c); tx = -(sx - nx); ty = -(sy - ny); } const float tmat[6] = {std::round( c * 1000) / 1000.0f, std::round(-s * 1000) / 1000.0f, std::round(tx * 1000) / 1000.0f, std::round( s * 1000) / 1000.0f, std::round( c * 1000) / 1000.0f, std::round(ty * 1000) / 1000.0f, }; switch(method) { case AF_INTERP_NEAREST: t_fn = &transform_n; break; case AF_INTERP_BILINEAR: t_fn = &transform_b; break; default: AF_ERROR("Unsupported interpolation type", AF_ERR_ARG); break; } // Do transform for image for(int yy = 0; yy < (int)odims[1]; yy++) { for(int xx = 0; xx < (int)odims[0]; xx++) { t_fn(out, in, tmat, idims, ostrides, istrides, nimages, 0, xx, yy); } } }
void WeightsManager::InitFromMetaInfo(std::list<WeightsMetaInfo> wmi_list, TableInterface* table_int) { // Reorder so that if a default value exists, it gets added last WeightsMetaInfo default_item; bool default_found = false; std::list<WeightsMetaInfo> new_list; BOOST_FOREACH(const WeightsMetaInfo& wmi, wmi_list) { if (!default_found && wmi.is_default) { default_item = wmi; default_found = true; } else { new_list.push_back(wmi); } } if (default_found) new_list.push_back(default_item); BOOST_FOREACH(const WeightsMetaInfo& wmi, new_list) { if (num_weights >= MAX_OPEN_WEIGHTS) return; wxFileName t_fn(wmi.filename); wxString ext = t_fn.GetExt().Lower(); if (ext != "gal" && ext != "gwt") { LOG_MSG("File extention not gal or gwt"); } else { if (ext == "gal") { GalElement* tempGal=WeightUtils::ReadGal(wmi.filename, table_int); if (tempGal != 0) { GalWeight* w = new GalWeight(); w->num_obs = observations; w->wflnm = wmi.filename; w->title = wmi.title; w->gal = tempGal; if (!AddWeightFile(w, wmi.is_default)) delete w; } } else { // ext == "gwt" GalElement* tempGal=WeightUtils::ReadGwtAsGal(wmi.filename, table_int); if (tempGal != 0) { GalWeight* w = new GalWeight(); w->num_obs = observations; w->wflnm = wmi.filename; w->title = wmi.title; w->gal = tempGal; if (!AddWeightFile(w, wmi.is_default)) delete w; } } } } }