Bug#365757: [Pkg-octave-devel] Bug#365757: octave-epstk: eps lines not optimized

Francesco Potorti` Potorti at isti.cnr.it
Fri May 12 16:25:49 UTC 2006


>> Very often, while plotting big quantities of data, I have redundant
>> points.  For example this X Y vector: 
>> 
>> 0 0                         0 0
>> 1 1			    1 1
>> 2 1			    8 1
>> 3 1			    8 4
>> 4 1			    9 5
>> 8 1  could be reduced to
>> 8 1
>> 8 2
>> 8 3
>> 8 4
>> 9 5
>> 
>> as far as plotting is concerned.  This optimisation reduces the size of
>> the eps file and the time it needs to be rendered either on screen or by
>> a printer.  I had cases where such an optimisation reduces the size by
>> ten times.
>
>I had some thoughts about this. My (personal) opinion is that this
>should not be implemented in a specific plot package, but as a general
>function.

Sure.  But such a function could be called by eplot.  I think that such
a function should be part of the eplot package for a start, and could be
removed from there if it becomes part of octave or octave-forge in a
future.

>Francesco, do you have such a simplifying function already?

No, but I have an algorithm for simplifying successive horizontal and
vertical segments, which are the most common case in my experience.  It
should be extended to general segments.

The algorithm is as follows (for horizontal segments only, just do it
twice by exchanging X and Y for vertical segments):

referenceY = invalid
for each segment		# segment is (X1,Y1)--(X2,Y2)
  if referenceY == invalid
    referenceY = Y1
    if Y2 != referenceY +/- slack
      referenceY = invalid
  else if Y2 == referenceY +/- slack
    merge the previous segment with the current one by removing the
    middle point
  else
    referenceY = invalid

slack should be set to something near the resolution of the plot, like
1/1000 of the plot size.

Maybe I will try to write it and let you know.

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 313 8091
via G. Moruzzi 1, I-56124 Pisa         Email: Potorti at isti.cnr.it
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key




More information about the Pkg-octave-devel mailing list