Jump to content

Image reduction in theory


Recommended Posts

As someone with an obsessive compulsive personality, I really need to understand what happens to an image when it's reduced. I know that the overall quality of the image is diminished. If 800 pixels are squeezed into 200 pixels, then something has to go, but just exactly how does that work?

Is there a simple mathematical equation (ratio proportion) that takes place? I'm mostly concerned about the lines of one or two pixels' width. In the process of reduction, are the single width lines the last to be affected?

Can someone please give me the benefit of their expertise? Thank you.

KORTECKGOLDGIFSIG455x100.gif
Link to comment
Share on other sites

Okay, it's fairly simple actually. Let's use your example of an 800x800 pixel image being reduced to 200x200. The simple part? The mathematics involved, 800/200 = 4. This means that if you shrink the image 800x800 to 200x800, the first of every four pixels horizontally is kept, and the remaining three are deleted (or blurred into the picture for some programs). So naturally you'll lose a lot of color and detail from this, and it's even worse when you don't stay to proportions.

Now this changes with the resolution. I'm used to dealing with 500+ resolution images, but if you're dealing with the standard ( 78 ) this will affect you far more than myself.

Another theory that may come from this is that instead of the first of the four, it's a randomly picked pixel of the four and then it goes on to the next column and so on.

I'm not 100% sure on this, but this would be the more logical approach if one had to assume what resizing actually does.

Sig2.jpg
Link to comment
Share on other sites

William, what you described is called nearest neighbor resampling.

In general, look at it like this. Let's say you're converting an 800-wide image to a 200-wide image. You have 4 input pixels (0 through 3) that all have to fit in to 1 output pixels (pixel 0 in the output). With nearest neighbor, you just grab input pixel 0 and put it in output pixel 0. Input pixel 4 goes into output pixel 1, and then input 7 goes into output 2, etc.

With super sampling you actually take the average of all of those pixels ... i0+i1+i2+i3 / 4 = o0, and then i4+i5+i6+i7 / 4 = o1. Each pixel is actually a quadtet of byte values, one for each color value, so you do this for each color channel individually.

Other algorithms such as bicubic, bilinear, etc. operate on similar principles: you take the input pixels, perform some linear combination on them, and that's how you compute the output pixels.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Ahh yes. But the goal is to not blur the picture :) I have this huge book on computer graphics that describes some really cool resampling methods I'd like to implement. Problem is that it's so mathematically intense and they don't really discuss it in practical terms (e.g. it's too much math, and not any code).

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Gahh I still can't put it right >.< (lol)

Yeah, so much math that to do any kind of hardcore Digital Photography editing that a minimum of a 2 GHz processor is basically required lol.

Plus having to type all that and then maybe end up finding errors and then having to locate where exactly that error is x.x Headaches (especially if there's dozens of lines of code).

Sig2.jpg
Link to comment
Share on other sites

Actually the image resampling code in Paint.NET comprises at least 1000 lines of code. And yeah some parts of it are pretty interesting, especially when you have to take into consideration alpha composition with premultiplied alpha and color values. "Ok it works, I'm never touching that again for a thousand years."

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Thank you both very much. I've been using nothing but best quality and had forgotten about the other resampling options. I didn't know what they were before, but now I have a better idea of what resampling means. Thanks for the links Rick. I'll study up this week.

For now though, I'll continue to use best quality and be sure to paint in proportion to the final size of the image. Thanks for that tip William.

KORTECKGOLDGIFSIG455x100.gif
Link to comment
Share on other sites

i recently needed bicubic interpolation (but not for an image program :)) and the source code of PdN was really very useful, especially the link you put in a comment from where to get the mathematical basis (would never have found that with any internet search engine on the world).

thank you for this being open source :D :wink:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...