[comp.graphics] stretching an image

hackeron@athena.mit.edu (Harris L Gilliam) (01/09/89)

Does anyone have an routine that can take an arbitrary monocrome image and 
stretch it in one direction (left to right) to conform to a diferent aspect
ratio without loosing pixels and keeping the image reletively smooth ?

I've seen things like this on MACs where bitmap images can be stretched and 
shrunk to arbitrary sizes without pixel loss and they stay reletively smooth 
looking.


								Harris






|  Harris L. Gilliam                   ()    4 Ames St. Cambridge MA 02139 |
|  Internet : hackeron@athena.mit.edu  () hgilliam@media-lab.media.mit.edu |
|  UUCP     : {backbone..}!mit-eddie!mit-athena!hackeron                   |
|For every complex problem,there's a solution that's simple,neat,and wrong.|

nelson@sun.soe.clarkson.edu (Russ Nelson) (01/09/89)

I've done it before, and I couldn't find nor create a way that's any better
than the obvious method:

  o Do a Bresenham's substituting OLD X for X and NEW X for Y.
  o With this list of X coordinates, do a Bresenham's substituting OLD
    Y for X and NEW Y for Y.  (Y can be a function of X if desired.
    This lets you stretch four sided rhombuses).
  o If you have more new pixels than old (in Bresenham's concepts, the
    line's slope is greater than 45 degrees) then you need to
    replicate old pixels.  This works pretty well in most cases.
  o If you have more old pixels than new then you have a decision to
    make.  You can either drop "extra" pixels (okay for continuous
    tone images, crummy for line images) or you can compute an average
    and truncate or you can do a Floyd-Steinburg dither, or any other
    technique for discarding information in a controlled manner or you
    can preserve black pixels (good for black on white line images) or
    you can preserve white pixels (good for white on black line
    images).

Can anyone help Harris and I by providing a better algorithm?
--
--russ (nelson@clutx [.bitnet | .clarkson.edu])
"I saved the whales!" - Rebecca L. Nelson, 3.5 years old, on receiving her
Christmas present of a whale "adoption" certificate.  Bless her liberal heart.