scaling
suppose you were given a sequence of sequences, representing
an image to be displayed, can anyone code a fast, readable,
scaling routine? both scaling up and down (zoom in or out)
are needed/desired.
the sequence format is a simple 2d representation of the image,
and each x,y coordinate location holds a 3-length sequence
for Blue,Green,Red, with each y holding an entire line of pixels.
(makes it easy to put the image back with 'pixel', as it deals with
entire lines at a time)
to wit:
x=1 x=2 x=3 x=4
image={ {{120,130,134},{231,212,20},{24,88,129},{128,128,128}}, --y=1
{{212,101,131},{142,245,11},{12,16,244},{161,233,212}}, --y=2
{{120,130,134},{231,212,20},{24,88,129},{128,128,128}}, --y=3
{{212,101,131},{142,245,11},{12,16,244},{161,233,212}} --y=4
}
this would be a simple 4x4 image, not very practical of course...
but say it was 50x50 and I wanted 60x60 or 200x200 out of that image?
say it was 400x400 and I wanted 300x300? Can that be done without
image degradation? A good example is paint shop pro and it's zoom
function... you can take a 2000x2000 picture and zoom out to where
it fits the screen (800x600 with an actual image size of 600x600)
and you can see that its the same picture...zooming in is a little
harder, you usually have to use "resample" to do anything but
minor zooming in...
so, a simple 'zoom out' for zooming out, and 'resample' for zooming in,
is what I'm asking... if 'resample' is an algorithm that's too complex,
I of course will settle for a simple zoom out...
Also, this routine should actually be
indifferent to what is held at each location (3bytes or 1 byte)
for the individual pixel data...at least in theory :)
however, it cannot be for specific image file formats...
scaling routines for 'bmp' or 'gif' etc... are verboten.
happy coding, and remember, keep that code clean ;) --Hawke'
|
Not Categorized, Please Help
|
|