How to randomly jitter pixels?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
tomsvilans
Posts: 1
Joined: 2013-12-12T05:41:17-07:00
Authentication code: 6789

How to randomly jitter pixels?

Post by tomsvilans »

Hi, first post!

I've written a script that keeps an eye on a folder of images, resizes them as they are created (using ImageMagick) and outputs to a different folder. The problem is a very distinct moire pattern (because of the nature of the images) that simple resizing doesn't get rid of.

Is there a way to apply a random jitter to the pixels of the original high-rez images before resizing? I think this should help the moire pattern in exchange for a bit of grain / noise in the resized image, but I want to see how that would look. Is there a simple pixel filter that randomly moves pixels over by a set amount (1-2 pixels)?

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to randomly jitter pixels?

Post by fmw42 »

tomsvilans wrote:Hi, first post!

I've written a script that keeps an eye on a folder of images, resizes them as they are created (using ImageMagick) and outputs to a different folder. The problem is a very distinct moire pattern (because of the nature of the images) that simple resizing doesn't get rid of.

Is there a way to apply a random jitter to the pixels of the original high-rez images before resizing? I think this should help the moire pattern in exchange for a bit of grain / noise in the resized image, but I want to see how that would look. Is there a simple pixel filter that randomly moves pixels over by a set amount (1-2 pixels)?

Thanks!

See -spread
http://www.imagemagick.org/script/comma ... php#spread

In IM, you can do something similar with the very slow -fx to apply a random offset to each pixel coordinate. See the rand() function at http://www.imagemagick.org/script/fx.php.

convert rose: -fx "ii=i+10*rand(); jj=j+10*rand(); u.p{ii,jj}" show:


But there are other resizing filters that may perform better with regard to moire artifacts. See
http://www.imagemagick.org/Usage/filter/
http://www.imagemagick.org/Usage/filter/nicolas/
Post Reply