Page 1 of 1

Random Pixel recoloring

Posted: 2018-01-09T23:23:40-07:00
by phresh55
Is there already a script or something that will recolor a random pixel of a batch of images?

Re: Random Pixel recoloring

Posted: 2018-01-10T08:40:00-07:00
by GeeMack
phresh55 wrote: 2018-01-09T23:23:40-07:00Is there already a script or something that will recolor a random pixel of a batch of images?
There are probably several simple ways to do what you're asking, but we need a lot more information to point you in the right direction. Look over the suggestions at "Read This First", then let us know what platform you're working on, which version of ImageMagick you're using, and provide a little better explanation of exactly what result you're trying to achieve.

Re: Random Pixel recoloring

Posted: 2018-01-10T11:14:03-07:00
by fmw42
Is it the same random pixel in all images or different random pixels in each image? Is it only one pixel that needs recoloring randomly? A better explanation or example images would help us understand your problem. Also always provide your IM version and platform since syntax and scripting may differ

You can compute a random number in Imagemagick using the "%[fx:random()]" with values between 0 and 1. You can scale the values by multiplying X*random() in the expression. You can compute that number once for w*random() and again for h*random. To get some random coordinate and then -draw a pixel of some color to that coordinate.

If you want to do this for all images at the same coordinate, then use mogrify to process all images in a directory at the same location. If you need each image to have a separate random coordinate changed, then you will need to write a script loop over each image.

See
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transform/#fx
http://www.imagemagick.org/Usage/draw/#primitives
http://www.imagemagick.org/Usage/basics/#mogrify