Just want to confirm, is you code for forward or backward
filter?

Пн, 01 сен 2014, Henry Rich написал(а):
> Well, I said it was untested.  It's just the framework.  Here's a version
> that at least produces a result:
> 
> 
> y =. i. 5 10
> 'height width'=: $y
> pixels=: ,y
> NB. convert to array, reverse, add bottom/right 0
> array =: ({.~ >:@$);.0 (height, width) $ pixels
> 
> NB. x is unused,above), y is left,upper-left
> NB. Result is Paeth predictor
> paeth =: (({~   (i. <./)@:|@:(- +`-/)))@:(}.@,)
> NB. x is unused,above), y is left,upper-left
> NB. Result is (new pixel total,next upper-left (same as input 'above')
> pixels2x2 =: (256 | [ + 2 {. paeth)
> NB. y is is a pair of scanlines (current,above)
> NB. transpose, then decompress on each 2x2 producing a table of
> NB. (uncompressed value,above).  Discard the above part, leaving a list
> scanlinepair =: 0 {"1 pixels2x2/\.@,.
> NB. Operate on each scanline-pair; reverse and remove added row/col
> xformimage =: 1 1&}.;.0 scanlinepair/\. array
> 
> 
> To support bpp you would need to keep an nx2 instead of a 2x2 history. Ecch.
> 
> Henry Rich
> 
> On 9/1/2014 11:04 AM, bill lam wrote:
> >I assume your code is for backward filter (from paeth to raw).
> >I tried with test data: y =. i. 5 10
> >'height width'=. $y
> >pixels=. ,y
> >
> >but it ran into error
> >|index error: scanlinepair
> >|   xformimage=.1 1&}.;.0     scanlinepair/\.array
> >
> >Also the bpp meant comparison with bpp byte apart. this bpp can
> >be 1 to 7 depending on pixel format. so that each of the current
> >and above line can be reshaped or partition before processing
> >the 2x2 blocks.
> >
> >
> >Пн, 01 сен 2014, Henry Rich написал(а):
> >>Untested.  Here is a framework.  It's not pretty, but this
> >>computation is just not parallelizable.
> >>
> >>NB. convert to array, reverse, add bottom/right 0
> >>array =. ({.~ >:@$);.0 (height, width) $ pixels
> >>
> >>NB. y is 2x2 of (unused,above),:(left,upper-left)
> >>NB. Result is Paeth predictor
> >>paeth =. ({~   (i. <./)@:|@:(- +`-/))@:(}.@,)
> >>NB. y is 2x2 of (new pixel diff,above),:(left,upper-left)
> >>NB. Result is (new pixel total,next upper-left (same as input 'above')
> >>pixels2x2 =. ({. + 2 {. 256 | paeth)
> >>NB. y is is a pair of scanlines (current,above)
> >>NB. transpose, then decompress on each 2x2 producing a table of
> >>NB. (uncompressed value,above).  Discard the above part, leaving a list
> >>scanlinepair =. 0 {"1 pixels2x2/\.@|:
> >>NB. Operate on each scanline-pair; reverse and remove added row/col
> >>xformimage =. 1 1&}.;.0 scanlinepair/\. array
> >>
> >>
> >>Henry Rich
> >>
> >>
> >>On 9/1/2014 1:44 AM, bill lam wrote:
> >>>Context for discussion, section 6.6 of this png rfc
> >>>
> >>>* http://tools.ietf.org/html/rfc2083
> >>>
> >>>The forward filter seems trivial, but the backward filter seems
> >>>tricky to me if not using loop.  Any idea on a loop free
> >>>solution?
> >>>
> >>>
> >>>NB. Paeth Predictor
> >>>paeth=: 3 : 0
> >>>p=. +/ 1 1 _1 * y
> >>>y{~ (i.<./) |p-y
> >>>)
> >>>
> >>>forward=: 4 : 0
> >>>prev=. 10$ 3 5 8
> >>>iy=. i.10
> >>>pae=. 256&| iy - paeth"1 ((-x)}.(x#0),iy),.prev,.((-x)}.(x#0),prev)
> >>>)
> >>>
> >>>    3 forward''
> >>>253 252 250 3 3 3 3 3 3 3
> >>>    4 forward''
> >>>253 252 250 0 1 0 4 2 0 6
> >>>
> >>>NB. backward ??
> >>>NB. 4 backward 4 forward ''
> >>>
> >>----------------------------------------------------------------------
> >>For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to