根据交错模式重新排列列表或列我指的是旧的隔行扫描视频技术中的隔行扫描,其中屏幕上的像素线将以每隔一行或每三行交替呈现。( https://en.wikipedia.org/wiki/Interlaced_video有一个很好的 gif 来展示这个过程)
所以如果你有行(1,2,3,4,..... 99)
它们将按行顺序(1,3,5,7......97,99,2,4,6,.....98)呈现(因子 2)
或(因子 3)作为行(1,4,7.....2,5,8.....3,6,9....)
我正在尝试使用 JSL 编写一个脚本,根据此模式对任意长度的序列进行重新排序,但我不太清楚如何构建索引来重新排序。我目前正在尝试计算矩阵数学来实现这一点,但也许 for 循环会更智能/更简单?
// Create arbitrary sequence
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,21,22,23,24,25,26,27,28];
f = 3 // interlacing factor<BR />
//Start trying to work out an index or grouping for a future sorting op
b = mod(a+f-1),3);
//b = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 2, 0, 1, 2, 0, 1, 2, 0]<BR />
// ????
自动化和脚本回复:根据交错模式重新排序列表或列嗨,凯西,
你是对的——我很抱歉! 试试这个代码,它在初始转置之前将额外的值设置为 missing ,这样它们可以在以后用 Loc() 清除。
Names Default To Here(1);
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];
fact = 3;
x = shape(a, ceiling(nrow(a)/fact));
try(x[(nrow(a)+1)::(nrow(x)*ncol(x))] = .);
x = shape(x`, 1);
x = x[loc(!ismissing(x))];
回复:根据交错模式重新排序列表或列
[1::nrow(a)]
删除第二个形状之后的环绕位置,因此不幸的是错误的值被截断了。
我用你给我的东西来标记环绕值(在这种情况下为 0,但也许 NaN 或其他东西会更好?)以便在操作结束时可以轻松识别和删除它们。 我知道我使用了太多变量,请忽略草率。
n = 28; // Number of rows
f = 3; // Interlacing factor (how many scans per frame)
q = ceiling(n/f);
r = q*f;
a = 1::r;
a[loc(a > n)] = 0; //a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 0 0];
s = shape(shape(a, q)`,1); //s = [1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 0 3 6 9 12 15 18 21 24 27 0];
b = s[loc(s)]; //b = [1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24 27];
show(b);
c = [];
For(i = 1, i <= nrow(b), i++,
c = c || a`[i] || b[i];
);
show(c`); //c` gives a vector to copy/paste into a match() function that will translate progressive rows to interlaced rows
回复:根据交错模式重新排序列表或列幸运的是,我仍然安装了 JMP14,所以我可以对其进行测试。 一种“解决方法”是这样的:
Names Default To Here(1);
// Create arbitrary sequence
a = Transpose(1::30);
f = 3;
b = AsList(Mod(a+f-1,f));
m_interlaced = [];
For(i = 0, i <= f-1, i++,
m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);
//m_interlaced = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30];
回复:根据交错模式重新排序列表或列在 JMP14 中,这返回“Argument should be list”,我相信指的是在 Loc 函数中调用 b 的位置。 我试图用 as list() 修改 b 但我不明白结果。
另外,|/ 是做什么的,它与 concat 运算符 || 有关系吗?
a = 1::30;
f = 3;
b = as list(Mod(a+f-1,f));
m_interlaced = [];
For(i = 0, i <= f-1, i++,
m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);
/*:
m_interlaced = [](0, 1);
回复:根据交错模式重新排序列表或列这似乎得到了正确的矩阵(如果起始矩阵的构建方式不同,可能需要转置)
Names Default To Here(1);
// Create arbitrary sequence
a = 1::30;
f = 3;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i <= f-1, i++,
m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);
Names Default To Here(1);
// Create arbitrary sequence
a = 1::99;
f = 2;
b = Mod(a+f-1,f);
m_interlaced = [];
For(i = 0, i <= f-1, i++,
m_interlaced = m_interlaced |/ a[Loc(b, i)];
);
show(m_interlaced);
回复:根据交错模式重新排序列表或列编辑#2:远低于不正确。 此代码应该工作:
Names Default To Here(1);
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27];
fact = 3;
x = shape(a, ceiling(nrow(a)/fact));
try(x[(nrow(a)+1)::(nrow(x)*ncol(x))] = .);
x = shape(x`, 1);
x = x[loc(!ismissing(x))];
////////////////////////
#EDIT:我不得不在末尾添加一个索引,以防止当因子没有平均划分行数时“重新开始”
/////////////
你好,
查看 Shape() 命令。 随着转置,你可以得到你想要的——
Names Default To Here(1);
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,21,22,23,24,25,26,27,28];
fact = 3;
shape(shape(a, ceiling(nrow(a)/fact))`, 1)`[1::nrow(a)]
干杯,
布雷迪