I am referring to interlacing as in older interlaced video techniques where the lines of pixels on your screen would be rendered in an alternating pattern of every second or every third row. (https://en.wikipedia.org/wiki/Interlaced_video has a good gif of the process)
so if you have your rows(1,2,3,4,.....99)
they would be rendered (factor 2) in the order rows(1,3,5,7......97,99,2,4,6,.....98)
or (factor 3) as rows(1,4,7.....2,5,8.....3,6,9....)
I'm trying to write a script that will reorder a sequence of arbitrary length according to this pattern with JSL but I can't quite figure out how to build an index to reorder this. I'm currently trying to work out matrix math to accomplish this but maybe a for loop would be smarter/easier?
// 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 />
// ????
EDIT: I had to add an index to the end to prevent "start-over" when the factor does not evenly divide the number of rows.
/////////////
Hi,
Check out the Shape() command. Along with transposing, you can get what you are after--
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)]
Cheers,
Brady
This seems to be getting correct matrices (might require transposing if starting matrix is built differently)
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);
in JMP14 this returns "Argument should be list" I believe referring to where b is called in the Loc function. I tried to modify b with as list() but i don't understand the result.
seperately, what does |/ do and is it related to the concat operator ||?
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);