PDA

Click to See Complete Forum and Search --> : Image scaling deformation correction


might
Sep 1st, 2001, 01:34 PM
You know, if you scale an image to a bigger size (e.g. with StrechBlt), it deforms. Because StrechBlt scales the image point by point (or pixel by pixel), so the every point of image starts to seem as awarable square, thus the image deforms.
But, if you have transformed an image by scaling in Adobe Photoshop, you know it corrects these deformations (as much as it can) like redrawing the image in the new size. The result is much better than StrechBlt`s.
My question is how can we do this in a VB project, I think an algorithm is required.
If you have an idea for how to do this, would you please share.
Thanks in advance.

Flustor
Sep 5th, 2001, 05:49 AM
I had exactly this problem in my final year project at University, object recognition stuff. If you run a smoothing algorithm after the scale it looks a bit better.

My idea of smoothing was to work along the picture pixel by pixel from top left to bottom right.
By moving around the current pixel I'd look at the ajoining pixels (the pixel directly above, above right, right...) and take an average of their colour and apply that to the current pixel.

Hope this helps

Flustor

Sastraxi
Sep 5th, 2001, 03:45 PM
Smoothing ACK!

It'll make it look blurry and all after the smooth, and what happens when they resize it just a couple of pixels ;) ouch! No quality.

So you do an algorithm called linear filtering (I believe) to do the work for you. It can be found in the Graphics Programming for Visual Basic 2nd edition, or maybe somewhere on the web. If you want to do this in real-time you must use DirectX or ASM code routines. DirectX is usually the way to go. If it doesnt matter about speed go for the pointer method suggested at lucky's vb gaming site in the tutorials section.

The address is http://rookscape.com/vbgaming/

As always, happy coding!