IMAGE_SWIRL
Download Flojoy Studio to try this app
Adjusts the gamma of an input image and outputs the adjusted image Params: default : Image The input image gain : float, default=1 The gain of the logarithmic correction. gamma : float, default=1 The gamma to correct to. Returns: out : Image The adjusted image.
Python Code
import numpy as np
from flojoy import Image, flojoy
from skimage.transform import swirl
@flojoy(deps={"scikit-image": "0.21.0"})
def IMAGE_SWIRL(
default: Image,
rotation: float = 0,
strength: float = 10,
radius: float = 120,
) -> Image:
"""
Adjusts the gamma of an input image and outputs the adjusted image
Parameters
----------
default: Image
The input image
gain: float, default=1
The gain of the logarithmic correction.
gamma: float, default=1
The gamma to correct to.
Returns
-------
Image
The adjusted image.
"""
r = default.r
g = default.g
b = default.b
a = default.a
if a is not None:
rgba_image = np.stack((r, g, b, a), axis=2)
else:
rgba_image = np.stack((r, g, b), axis=2)
corrected_image = swirl(
rgba_image,
rotation=rotation,
strength=strength,
radius=radius,
)
r = corrected_image[:, :, 0]
g = corrected_image[:, :, 1]
b = corrected_image[:, :, 2]
if a is not None:
a = corrected_image[:, :, 3]
return Image(r=r, g=g, b=b, a=a)
Example App
Having problems with this example app? Join our Discord community and we will help you out!
In this example, two image transformation were performed.
First the necessary blocks were added: SKIMAGE
to fetch the example image, 3 IMAGE
blocks to view the images, ROTATE_IMAGE
, AND IMAGE_SWIRL
.
The degree
parameter for ROTATE_IMAGE
controls the degrees of rotation and was set to 45, and the radius
parameter of IMAGE_SWIRL
was set to 750. The SKLEARN
image was set to camera
. The remaining parameters were left at default values
The blocks were connected as shown and the app was run.
Try changing the mode
of the image rotation block and view the changes.