2024-09-24 02:17:20 发布
网友
在下面的函数imcrop_tosquare。 假设我有一个形状的图像(8,4) 即8行4列。 如果是这样的话。我将得到额外的4岁。 然后extra%2 ==0条件得到满足。在
imcrop_tosquare
extra%2 ==0
crop = img[2:-2,:]
2比2代表什么? 我想是从第二排到前一排。 1,2,3,4,5,6,7,8[这将在循环中]所以-1是1,-2是2。 如果把前两行结束,图像会不会损坏?? 我解释错了吗?有谁能指导我理解这一点吗。在
根据documentation:
Negative i and j are interpreted as n + i and n + j where n is the number of elements in the corresponding dimension.
所以如果数组中有8行,crop = img[2:-2,:]将意味着crop = img[2:6,:]
crop = img[2:6,:]
根据documentation:
所以如果数组中有8行,
crop = img[2:-2,:]
将意味着crop = img[2:6,:]
相关问题 更多 >
编程相关推荐