That sounds very much like a description of # with a boolean left argument.
If the left argument of sample becomes the sub-pixel index of interest
sample=: 4 : 'wind x&{@,;._3"2 y'
we can define a workalike using #
samp=:4 :0
'row col'=. (_2 {. #: 4+x)=/0 1
'height width'=. $y
(height$row)# (width$col)#"1 y
)
In other words:
dat=: ?.8 8$2
0 (samp -: sample) dat
1
1 (samp -: sample) dat
1
2 (samp -: sample) dat
1
3 (samp -: sample) dat
1
Note that we could also incorporate the arbitrary choice of the pixel
being picked into samp, but that would make testing a problem. (We
could do it by making the random choice mechanism be a user defined
verb and then for testing purposes we could supply a specialized
definition of that verb, but I am not sure that that is warranted for
the current definition of sample.)
FYI,
--
Raul
On Tue, Jan 1, 2013 at 12:47 PM, Brian Schott <[email protected]> wrote:
> I have been reading -- no scanning -- apple developer's docs (because
> ultimately my code is developed in apple's Xcode) on math|digital
> signal processing and I am seeing talk of existing procedures that do
> dot products, FFT, convolutions, and scaling in the same docs.
>
> In particular there is mention at the link below of a function
> vDSP_vcmprs which has the following desctiption.
>
> "Performs the following operation:
>
>
> "Compresses vector A based on the nonzero values of gating vector B.
> For nonzero elements of B, corresponding elements of A are
> sequentially copied to output vector C."
>
> http://developer.apple.com/library/ios/#documentation/Accelerate/Reference/vDSPRef/Reference/reference.html
>
> This looks very promising to me if I can figure out the inputs which
> include 2 input vectors and 1 output vector and 3 corresponding
> "strides". I assume input vector A would be my raveled 52x52 image of
> 0s and 1s; input B would be some permutation of 1, 3#0 or of 1,15# 0.
> Would the stride of A be 52 and the stride of B be 4 or 16? Does C
> have a stride?
>
> Can anyone help here?
>
>
> On Mon, Dec 31, 2012 at 6:07 PM, Brian Schott <[email protected]> wrote:
>> I developed a small image compression script which is applied to a
>> "thresholded" image from the G component only of the RGB triplet. (Although
>> my example below is of an 8x8 thresholded image, in practice it is 52x52.)
>>
>> wind=: 2 2$2
>> sample=: 4 : 'wind (?x)&{@,;._3"2 y'
>> ]specimen=: 8 8?.@$2 NB. the test thresholded image
>> 0 1 0 1 1 1 0 0
>> 0 1 0 1 0 0 1 0
>> 0 0 0 0 1 1 1 0
>> 0 0 0 0 1 1 0 1
>> 1 0 0 1 0 0 1 0
>> 1 0 0 0 0 1 0 1
>> 0 0 1 0 0 1 0 0
>> 1 0 0 1 0 1 0 0
>> 2 (4&sample) specimen NB. a random resulting compression
>>
>
>
>
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm