We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Smooth() doesn't seem to do anything with image
Page Index Toggle Pages: 1
Smooth() doesn't seem to do anything with image (Read 618 times)
Smooth() doesn't seem to do anything with image
Oct 29th, 2009, 12:34am
 
I am making a program which resizes an image and saves it as .jpg
Resizing works, but the image is aliast.  I read smooth() should enhance the resize quality but I can't see any difference. Am I doing something wrong?

In this test code both img and img2 look the same:

Code:
size(500, 500);

PImage img = loadImage("landrover.jpg");
PImage img2 = loadImage("landrover2.jpg");

smooth();
image(img, 0, 0,250, 190);

noSmooth();
image(img2, 250, 0,250, 190);


And in this test code also img and img2 look the same:

Code:
size(500, 500);

PImage img = loadImage("landrover.jpg");
PImage img2 = loadImage("landrover2.jpg");

smooth();
img.resize(250, 190);
image(img, 0, 0);

noSmooth();
img2.resize(250, 190);
image(img2, 250, 0);


Hope someone can help.
Re: Smooth() doesn't seem to do anything with image
Reply #1 - Oct 29th, 2009, 4:48am
 
I am not sure why you compare two different (?) images. And we don't know the original size. Do you scale up or down?
I did a quick test, similar to your:
Code:
size(500, 500);

// Small, clean 48x48 image
PImage img = loadImage("clock.gif");

image(img, 0, 0);
// Default
image(img, 250, 0, 250, 250);

smooth();
image(img, 0, 250, 250, 250);

noSmooth();
image(img, 250, 250, 250, 250);

The two right images are identical, confirming default is noSmooth. They are pixelized, as if each pixel is inflated to a big monochrome square block.
The smoothed one is still a bit pixelized (the method doesn't do miracles, even if some miraculous algorithms exist) but much smoother, the diagonal lines are antialiased, less blocky.

So I can at least confirm there is a difference in resize when you enable smoothness.
Re: Smooth() doesn't seem to do anything with image
Reply #2 - Oct 29th, 2009, 5:12am
 
Sorry, I am scaling down from a (very) large image.
In you're example I can see the difference between the smooth() and noSmooth() images.

I was comparing the two images so I could see a difference between the two

But I was hoping the way of down scaling would be effected by smooth(), like Nearest Neighbor and  Bicubic.

Is there maybe another way to scale down images, so sharp edges in the image won't look like stairs.

I tried using OPENGL, it smooths the picture better although a little to much.
And when using save() there's a gray horizontal line in the middle of the generated jpg.
Page Index Toggle Pages: 1