flag_noPSD = 0 if (p_obj.get('S') == None).any(): S = gen_PSD(p_obj) p_obj['S'] = S flag_noPSD = 1 MVx = np.real(np.fft.ifft2(p_obj['S'] * np.random.randn(2 * p_obj['N'], 2 * p_obj['N']))) * np.sqrt(2) * 2 * p_obj['N'] * (p_obj['L'] / p_obj['delta0']) MVx = MVx[round(p_obj['N'] / 2) :2 * p_obj['N'] - round(p_obj['N'] / 2), 0: p_obj['N']] #MVx = 1 / p_obj['scaling'] * MVx[round(p_obj['N'] / 2):2 * p_obj['N'] - round(p_obj['N'] / 2), 0: p_obj['N']] MVy = np.real(np.fft.ifft2(p_obj['S'] * np.random.randn(2 * p_obj['N'], 2 * p_obj['N']))) * np.sqrt(2) * 2 * p_obj['N'] * (p_obj['L'] / p_obj['delta0']) MVy = MVy[0:p_obj['N'], round(p_obj['N'] / 2): 2 * p_obj['N'] - round(p_obj['N'] / 2)] #MVy = 1 / p_obj['scaling'] * MVy[0:p_obj['N'], round(p_obj['N'] / 2): 2 * p_obj['N'] - round(p_obj['N'] / 2)] img_ = motion_compensate(img, MVx - np.mean(MVx), MVy - np.mean(MVy), 0.5) #plt.quiver(MVx[::10,::10], MVy[::10,::10], scale=60) #plt.show() if flag_noPSD == 1: return img_, p_obj else: return img_, p_obj
时间: 2023-06-25 21:06:24 浏览: 53
这段代码看起来像是用来进行图像运动补偿的。首先检查输入的参数p_obj中是否有PSD(Spectral Density),如果没有则生成一个PSD。生成MVx和MVy,然后对输入的图像进行运动补偿,得到补偿后的图像img_。最后根据是否生成了PSD来返回img_和p_obj或仅仅返回img_和p_obj。
相关问题
const tipsStatus = function (item) { let obj = { class: "not-poiid", text: "", href: "javascript:void(0);", } if (item.is_stop_service == 1) { obj.text = "" } else if (!item.poiid && item.buy_type == 3 && item.is_white == 0) { obj.text = '优惠服务仅支持授权新店铺,请尽快授权!' } else if (!item.poiid) { obj.text = '未完成授权,请及时授权店铺' } else if (item.is_shenhe == 3) { obj.class = 'stop-service' obj.text = '店铺授权已失效' } else if (item.poiid && !item.sn) { obj.text = '第3步:设置打印小票模板并保存完成' obj.href = `addShop.php?pro=1&sid=${item.sid}&pid=${item.pid}` } return obj } 优化以上代码
可以将一些重复的条件判断合并,同时使用三元表达式简化代码:
```
const tipsStatus = function (item) {
let obj = {
class: "not-poiid",
text: "",
href: "javascript:void(0);",
}
if (item.is_stop_service == 1) {
obj.text = "";
} else if (!item.poiid) {
if (item.buy_type == 3 && item.is_white == 0) {
obj.text = '优惠服务仅支持授权新店铺,请尽快授权!';
} else {
obj.text = '未完成授权,请及时授权店铺';
}
} else if (item.is_shenhe == 3) {
obj.class = 'stop-service';
obj.text = '店铺授权已失效';
} else {
obj.text = !item.sn ? '第3步:设置打印小票模板并保存完成' : '';
obj.href = !item.sn ? `addShop.php?pro=1&sid=${item.sid}&pid=${item.pid}` : '';
}
return obj;
}
```
var obj = { a: 7, get b() { return this.a + 1; }, set c(x) { this.a = x / 2 } }; console.log(obj.b) obj.___ = 40 console.log(obj.b) 预期输出结果: 8 21
根据给出的代码,预期输出结果是错误的。的输出结果应该是:
8
21
在代码中,`obj.b` 是一个 getter 方法,每次调用 `obj.b` 时会返回 `this.a + 1` 的值,即 `7 + 1 = 8`。所以第一次输出结果是 `8`。
接下来,我们尝试设置 `obj.c` 的值为 `40`,这会触发 setter 方法 `set c(x)` 中的代码。在这个方法中,我们将 `x` 的值除以 `2` 并赋给 `this.a`。所以 `this.a` 的值变为 `40 / 2 = 20`。
最后,我们再次调用 `obj.b`,此时 `this.a` 的值为 `20`,所以输出结果是 `20 + 1 = 21`。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)