How would I perform many random operations to a set of images?
-
27-09-2019 - |
문제
I need to manipulate an image such that a sub-rectangle of it is flipped or rotated relative to the rest of the image. Here's an example:
This manipulation needs to happen many times, each time producing a new modified image from the original (rather than applying successive modifications to one image).
The size of the sub-rectangle needs to vary systematically (perhaps in 5% increments from 10% to 75%) and the location of the sub-rectangle needs to vary randomly.
Lastly, this procedure needs to be carried out on a large number of images.
How would I go about this?
My options are PHP, C#, or batching in Gimp. That said, I'm prepared to learn something new if there's a particularly sensible approach.
해결책
Id say go with C# and write yourself a little utility.
The Graphics
class may have all of the methods that you need.
Id suggest that you look at the DrawImage
and the RotateTransform
functions.
다른 팁
Is this something that needs to be done programatically or is it a one-time deal?
If programatically, it *can* be done in PHP using the GD library, but its not going to be easy or fast, due to the fact that you'll have to write a routine to manually move pixels.
A summary of "easyness" of your request based on a PHP GD library approach:
- Manipulation happens many times, each time producing a new modified image from the original: easy
- Size of the sub-rectangle needs to vary systematically, easy
- Location of the sub-rectangle needs to very randomly, easy
- In-image rotation moderate difficulty, and slow
- Performing this on a large number of images, easy
I don't have enough experience in C# of Gimp to give you any definitive answers there; Sorry.
You could take your favourite language, they will all 3 be capable, code it and run it?