Jump to content
N-Europe

Resizing images with no quality loss


Charlie

Recommended Posts

This isn't a question about how to resize images but a question about why you can't resize images this way without losing quality.

 

If I were to take an image which was 4x4 pixels, as below, and then upscale the image by taking each pixel individually, copy the colour exactly and place it in the pixel-slot to it's right, bottom and bottom-right. Then repeat this for every single other pixel in the image/photo would this not upscale it exactly by 4 with no quality loss?

 

Is there any reason why this wouldn't actually work? You are maintaining the aspect ratio of the pixels exactly and getting the exact colour.

 

UbIiD.jpg

 

Obviously that is a small scale example but if you were to create a script which did it for you the process could be automatic?

Link to comment
Share on other sites

Well the obvious issue is that you could only enlarge it by integer factors. That's gonna seriously limit your options, particularly for larger images.

 

Also you're essentially just creating massive pixels, so when it's larger you're going to see huge blocks of colour (whereas when it's small your eyes can't distinguish between them), so it will look really jaggy and pixelated.

 

For example, take a small circle. If you zoom in you'll see that it's pixelated, but because it's so small you can't tell. You scale that up exactly how it is then those pixels are going to become visible, and the small sharp edges that your eyes smoothed over will now be a few mm long.

Link to comment
Share on other sites

For example, take a small circle. If you zoom in you'll see that it's pixelated, but because it's so small you can't tell. You scale that up exactly how it is then those pixels are going to become visible, and the small sharp edges that your eyes smoothed over will now be a few mm long.

 

Would it be possible to then smooth over these pixels do you think? I get what you're saying and thought that something like that could be the case but it's something I actually thought about years ago at school. It's just come up again because I was trying to upscale an image earlier with minimum quality loss.

 

I'm pretty good with Photoshop but thought of this method a while back and thought I'd have a look around in case anyone else had thought the same as me.

Link to comment
Share on other sites

Wouldn't you be doing essentially the same thing as Photoshop at that point? :hmm:

 

It just seems kind of weird to increase the size of the pixels to keep the picture exactly the same, and then... attempt to smooth it out.

Link to comment
Share on other sites

Would it be possible to then smooth over these pixels do you think? I get what you're saying and thought that something like that could be the case but it's something I actually thought about years ago at school. It's just come up again because I was trying to upscale an image earlier with minimum quality loss.

 

I'm pretty good with Photoshop but thought of this method a while back and thought I'd have a look around in case anyone else had thought the same as me.

 

As Magnus said that's the sort of thing that Photoshop and other editing software does already.

 

And you're talking about creating a script for it. That's gonna to be incredibly difficult, especially when you're talking about more complex images with numerous different colours and gradients.

Link to comment
Share on other sites

Is there any reason why this wouldn't actually work? You are maintaining the aspect ratio of the pixels exactly and getting the exact colour.
To greatly simplify the reason why it wouldn't work is that a pixel is only the smallest thing we are able to create images out of digitally. It's not perfect as it is, so once it's doubled, those imperfections are just going to become clearer.

 

What you're talking about is no different to essentially setting your monitor to a lower resolution on the same aspect ratio.

Link to comment
Share on other sites

This isn't a question about how to resize images but a question about why you can't resize images this way without losing quality.

 

If I were to take an image which was 4x4 pixels, as below, and then upscale the image by taking each pixel individually, copy the colour exactly and place it in the pixel-slot to it's right, bottom and bottom-right. Then repeat this for every single other pixel in the image/photo would this not upscale it exactly by 4 with no quality loss?

 

Is there any reason why this wouldn't actually work? You are maintaining the aspect ratio of the pixels exactly and getting the exact colour.

 

UbIiD.jpg

 

Obviously that is a small scale example but if you were to create a script which did it for you the process could be automatic?

That image reinforces what pixellation is, it already looks like a badly blown up image when you resize it.

 

Just imagine those blocks as part of someone's face. Now you're using a single colour over a wider area than when the image was smaller. So basically it will always look patchy/blocky.

 

Doesn't raising the dpi fix this issue? I'm not a pro but I've previously read that raising the resolution to at least 300 will make it look much better when printed.

 

Yeah. Journal papers usually require 300 dpi + images so they print well and so you can zoom in far in online PDFs.

Link to comment
Share on other sites

 

UbIiD.jpg

 

Obviously that is a small scale example but if you were to create a script which did it for you the process could be automatic?

 

Actually photoshop can do this when you change some settings.

If you go to edit -> preferences -> general and change "image interpolation" to "nearest neighbor"

 

If you then resize a picture to a bigger size photoshop will remain the "hard" pixel edges.

 

I don't believe this is ideal for photo's or artwork though. I think this function is mainly used to resize pixel art

Link to comment
Share on other sites

Can't you just point at the thing you want to enlarge and say "Enhance that image"? That's how they do it on 24.

 

Ah, the technology to enhance a batch of four pixels into a fully-detailed face capable of being matched to one person on the planet.

Link to comment
Share on other sites

Bitmaps (pictures made of dots) can not be enlarged without badly degrading the quality of the images. All the TV crime shows with 'image enhancement' that show a clear pic of a mans face created from a video surveilance image of 6 pixels are rubbish! Vector images are able to be resized as large or small as you want and will not lose quality as they are not a record of pixels and colours, but rather a mathematical way of describing an image.

 

Cheers

 

Ross

Link to comment
Share on other sites

I don't know if I'm being dumb, but is Charlie saying that computers don't already do what he's suggesting in the first post? If not, what do they do?

They generally use a more efficient algorithm which tries to "guess" what the mixing pixels are, so the whole thing is smoothed, often with anti-aliasing pixels being added and so on. Different programs use different algorithms - for instance I'm pretty sure paint uses a much crappier algorithm, as I think I can see the difference. And as M_rock pointed out, some programs have a setting that will apply Charlie's algorithm, but in most cases the more sophisticated algorithms are what you want.

 

Edit: Let's assume we have a 14x14 image that looks like this when zoomed in:

 

lX81u.png

 

If we enlarged it to 500x500 in exactly the way Charlie suggests, it would come out looking exactly as above - which is great, until we realise that it's not the pixels we want to retain, but what the pixels represent, which is a circle in this case. So the photoshop algorithm tries to guess what things "really" look like, which comes out like this:

 

aNBpJ.png

 

Now, this doesn't look great, because 14x14 to 500x500 is such a difficult task, but it is sort of getting there in that the circle is somewhat smoothed.

 

If we use a real case instead, the superiority of the Photoshop algorithm is clearer. Let's say we start with this little image:

 

v8twr.png

 

We can resize it using Charlie's method, which comes out all pixelly like this:

 

JcMcU.png

 

Or we can use a better algorithm, which makes things look smoother:

 

bwEtn.png

 

Of course, any resizing is going to look bad in some way, as what we're doing is trying to reconstruct information that isn't there. But if we want to get more than just a bunch of pixels, a more complex algorithm is called for.

Edited by Supergrunch
Link to comment
Share on other sites

×
×
  • Create New...