|
Image processing Displaying 1-8 of 8 total.
1
Interference22
|
I'm not terribly well versed when it comes to the subject of processing images so I require a little enlightenment. My query is thus:
In VERGE, if you snap a shot of the screen to an image handle and then ScaleBlit it to reduce the size - say, for a save game screenshot - it looks bloody awful because V3 makes no attempt to shrink the image smoothly; it looks grainy. So, my question is how would I go about writing some VC that took an image and smoothly shrunk it down to any size I wanted in a similar way to the resize function of Photoshop or Painshop Pro?
Posted on 2006-03-01 17:29:14
|
Omni
|
That's not necessarily the problem.
The problem is that it's easy to smooth jaggies on a scaled image because you can interpolate, reprocess, etc.
The problem with scaling down an image is that smoothing it doesn't work like normal -- because any type of enhancement adds detail, but the process of scaling down doesn't add detail at all.
What kind of enhancement takes detail away, yet still makes it look like the original image?
I can't think of one.
Any smoothing we could do to make the image look better at a smaller size would inevitably remove even more detail from the image.
Why? Because scaling an image down means that we're having to cut out information. The jagged result, is, in fact, the most accurate version of the original image.
Keep in mind that Verge can do a really easy enhancement: interpolation.
1. Take target image.
2. Create new image handle (to hold final product). Can be bigger (scaled down) or larger (scaled up) than original image. Or the same size.
3. Blit the image with a 50% lucent Additive Blit onto the target image handle. Blit it again with a one pixel offset, etc.
Essentially, this means that each pixel on the target image receives data from two pixels: 50% from the left, 50% from the right (assuming you offset the second AdditiveBlit to the right by 1 pixel).
By combining a series of AdditiveBlits at one-pixel offsets you can achieve decent looking interpolation without the slowness of Setpixel.
For horizontal and vertical interpolation, I do 25% AdditiveBlits with a 0, 0 offset (X, Y); a 1, 0 offset, a 0, 1 offset, and a 1, 1 offset. (Essentially I offset the picture within a 2x2 pixel wide square.
Use interpolation to smooth your image scales. NOTE: If we scale down, scale the image down, then interpolate it. Interpolating it and then scaling down...well, I dunno. That could work. You'll lose detail either way, remember.
NOTE: to interpolate a picture means to use it as the source of the interpolation procedure described above. The result would be an interpolated version of the picture within the new destination image handle declared in step #2.
Posted on 2006-03-01 18:08:59
|
Omni
|
Pardon: interpolating the image first and _then_ scaling it down will preserve the most detail.
Why? If you scale an image down and then interpolate it, we are interpolating (thus creating new details) from the scaled down version of the image.
If we interpolate the image, and then scale it down, we still lose detail. But, the pixels, having already been interpolated, represent much more information than [image gained when scaled down and THEN interpolating].
Why is this? If interpolating 50% horizontally means, that from left to right, each pixel has 50% of the data to the left, and 50% of the pixel data to the right, then when we scale it down, that information is _still there_ in the pixels that aren't lost in scaling.
So in essence, scaling an interpolated image down doesn't destroy the interpolated data that is left in the pixels that survive scaling. We have 'crammed' additional data into each pixel, so to speak.
If we scale down first, and then interpolate, we are inventing new detail, yes, but we are doing it only from the remnants of pixels that weren't destroyed. It is much better to preserve data from as many pixels as possible before scaling: therefore, the final product represents more of the original data, and not just stuff we made up after we destroyed the original data.
Posted on 2006-03-01 18:18:35
|
adderd
|
The problem with your second email is that, while it may preserve the most detail, it won't look as nice as scaling then interpolating. I just figured I should mention that so that people can make an informed decision. There's the technically more accurate approach and the technically better looking (or smoother looking) approach.
Interpolating and then scaling will probably still leave some jaggies where as scaling then interpolating would make a more smooth appearance. It's totally up to the user I guess.
On a related note, I don't think it would necessarily be a bad idea to add an interpolated blit to verge so that scaled images could be automatically smoothed. Maybe it's a worthy inclusion into the engine and maybe not. It would most likely get my vote.
Posted on 2006-03-01 20:40:03
|
Omni
|
Interpolating then scaling has another huge advantage:
You can interpolate once, ScaleBlit always.
Rather than, say, ScaleBlit and then have to interpolate every single time.
So, not as smooth-looking, but it is definitely smoother, preserves more detail, and is faster.
Pre-interpolation for the win! :)
Posted on 2006-03-01 21:14:38
|
Omni
|
Adderd is right though: post-scale interpolation smoothes the final picture better.
Posted on 2006-03-01 21:16:11
|
adderd
|
I do like your idea of interpolating once and being able to blit smaller multiple times though. That does sound like a more efficient route. Still seems like the choice should be left up to the game designer as I could see someone deciding either way.
Posted on 2006-03-01 21:44:44
|
Interference22
|
Well, I <ithink I got all that. I'll give your suggestions a go and tell you how I got on..
Posted on 2006-03-02 18:22:15
|
Displaying 1-8 of 8 total.
1
|
|