From 26bdd7d7990645afbc7c5239464ab631930524dc Mon Sep 17 00:00:00 2001 From: "Alexander G. Morano" Date: Sat, 1 Mar 2025 18:29:21 -0500 Subject: [PATCH] direct mask support for `TRANSFORM NODE` --- README.md | 3 +++ core/compose.py | 10 ++++++++-- pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f16c60..cb6ac1d 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,9 @@ You can colorize nodes via their `title background`, `node body` or `title text` TICK Node Batch Support Output +**2024/02/25** @1.7.30: +* direct mask support for `TRANSFORM NODE` + **2024/02/25** @1.7.28: * fixed import bug in widget_vector * cleaner akashic output diff --git a/core/compose.py b/core/compose.py index 12c009e..74e177f 100644 --- a/core/compose.py +++ b/core/compose.py @@ -1008,6 +1008,7 @@ Apply various geometric transformations to images, including translation, rotati d = deep_merge(d, { "optional": { Lexicon.PIXEL: (JOV_TYPE_IMAGE, {}), + Lexicon.MASK: (JOV_TYPE_IMAGE, {}), Lexicon.XY: ("VEC2", {"default": (0, 0,), "mij": -1, "maj": 1, "step": 0.01, "label": [Lexicon.X, Lexicon.Y]}), Lexicon.ANGLE: ("FLOAT", {"default": 0, "step": 0.01}), Lexicon.SIZE: ("VEC2", {"default": (1., 1.), "mij": 0.001, "step": 0.01, "label": [Lexicon.X, Lexicon.Y]}), @@ -1029,6 +1030,7 @@ Apply various geometric transformations to images, including translation, rotati def run(self, **kw) -> Tuple[torch.Tensor, ...]: pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None) + mask = parse_param(kw, Lexicon.MASK, EnumConvertType.IMAGE, None) offset = parse_param(kw, Lexicon.XY, EnumConvertType.VEC2, [(0, 0)], -2.5, 2.5) angle = parse_param(kw, Lexicon.ANGLE, EnumConvertType.FLOAT, 0) size = parse_param(kw, Lexicon.SIZE, EnumConvertType.VEC2, [(1, 1)], 0.001) @@ -1044,11 +1046,15 @@ Apply various geometric transformations to images, including translation, rotati wihi = parse_param(kw, Lexicon.WH, EnumConvertType.VEC2INT, [(512, 512)], MIN_IMAGE_SIZE) sample = parse_param(kw, Lexicon.SAMPLE, EnumInterpolation, EnumInterpolation.LANCZOS4.name) matte = parse_param(kw, Lexicon.MATTE, EnumConvertType.VEC4INT, [(0, 0, 0, 255)], 0, 255) - params = list(zip_longest_fill(pA, offset, angle, size, edge, tile_xy, mirror, mirror_pivot, proj, strength, tltr, blbr, mode, wihi, sample, matte)) + params = list(zip_longest_fill(pA, mask, offset, angle, size, edge, tile_xy, mirror, mirror_pivot, proj, strength, tltr, blbr, mode, wihi, sample, matte)) images = [] pbar = ProgressBar(len(params)) - for idx, (pA, offset, angle, size, edge, tile_xy, mirror, mirror_pivot, proj, strength, tltr, blbr, mode, wihi, sample, matte) in enumerate(params): + for idx, (pA, mask, offset, angle, size, edge, tile_xy, mirror, mirror_pivot, proj, strength, tltr, blbr, mode, wihi, sample, matte) in enumerate(params): pA = tensor2cv(pA) if pA is not None else channel_solid(chan=EnumImageType.BGRA) + if mask is not None: + mask = tensor2cv(mask) + pA = image_mask_add(pA, mask) + h, w = pA.shape[:2] pA = image_transform(pA, offset, angle, size, sample, edge) pA = image_crop_center(pA, w, h) diff --git a/pyproject.toml b/pyproject.toml index 5fb3469..e479197 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "jovimetrix" description = "Integrates Webcam, MIDI, Spout and GLSL shader support. Animation via tick. Parameter manipulation with wave generator. Math operations with Unary and Binary support. Value conversion for all major types (int, string, list, dict, Image, Mask). Shape mask generation, image stacking and channel ops, batch splitting, merging and randomizing, load images and video from anywhere, dynamic bus routing with a single node, export support for GIPHY, save output anywhere! flatten, crop, transform; check colorblindness, make stereogram or stereoscopic images, or liner interpolate values and more." -version = "1.7.28" +version = "1.7.30" license = { file = "LICENSE" } readme = "README.md" authors = [{ name = "Alexander G. Morano", email = "amorano@gmail.com" }]