ML icon indicating copy to clipboard operation
ML copied to clipboard

Added new image rotator transformer.

Open Boorinio opened this issue 3 years ago • 0 comments
trafficstars

Hello again, This pr introduces the Random image rotation transformer, a very important one imo. The constructor gets the maximum degrees of rotation and then it applies it to the gd image while keeping the same center and cropping the rest of the image to fit the initial width and height. Here is an example on how it works on the ISIC dataset.

From left to right: Original Image, rotated image, cropped image to fit the original size image

Boorinio avatar Jul 10 '22 10:07 Boorinio

I have reviewed the PR and run the tests locally after merging it with current master. It all looks good.

Image rotation is a particular case of applying a rigid transformation to the image. We can start with a rotation and leave other transformations for other classes or extend this class as needed.

My only comment is the use of the color black as the background to fill the empty parts. First, using "0" in the code to mean black is a little hard to grasp (I had to read up on imagerotate to see it). Second, this color might be worth parameterizing. Other options include using the color in the "border" of the image, represented, for example, by the pixel in the upper left corner. But this might all be just feature creep.

Let us see what Andrew has to say. Very nice PR!

DrDub avatar Sep 05 '22 02:09 DrDub

Hey @Boorinio and @DrDub sorry it took me so long ... Yeah I agree super cool feature and I think the implementation is on point. I could go either way on parameterizing the "fill" color, for now we could leave it out and then parameterize it later without breaking backwards compatibility (default value will be vanta black (000)).

andrewdalpino avatar Sep 13 '22 00:09 andrewdalpino

We'll release this in 2.2!

andrewdalpino avatar Sep 13 '22 00:09 andrewdalpino