Nodes/ComfyUI-PJLatent/PJ 图像切片原位还原器
ComfyUI Node

PJ 图像切片原位还原器

Put your edited tiles back in place — seam-free, and nothing else moves

By pongjoo·Created 7 months ago·Updated 3 days ago· 0
PJ 图像切片原位还原器
  • 基底原图
  • 批次替换图片
  • 块1_图片
  • 块2_图片
  • 块3_图片
  • 块4_图片
  • 块5_图片
  • 块6_图片
  • 块7_图片
  • 块8_图片
  • 块9_图片
  • 块10_图片
  • 块11_图片
  • 块12_图片
  • 块13_图片
  • 块14_图片
  • 块15_图片
  • 块16_图片
  • 块17_图片
  • 块18_图片
  • 块19_图片
  • 块20_图片
  • 块21_图片
  • 块22_图片
  • 块23_图片
  • 块24_图片
  • 块25_图片
  • 块26_图片
  • 块27_图片
  • 块28_图片
  • 块29_图片
  • 块30_图片
  • 还原后图像
  • 替换区域遮罩
  • 还原汇总信息
边缘羽化像素16
分辨率处理模式缩放替换块至原切片尺寸 (维持基底分辨率)
切片数据
批次对应块序号

So you sliced a big image into a grid, upscaled or re-inpainted one tile in glorious high resolution, and now you face the part everyone dreads: putting it back without a visible rectangle where you pasted. PJ_Image_Slice_Reassembler (pongjoo/ComfyUI-PJLatent, menu "PJ_Nodes/Image") is the return half of the pack's slice-edit-stitch loop - it reads the exact tile coordinates from the slicer, drops your edited tiles into their original spots, and feathers the seams with a cosine blend so the patch reads as part of the image rather than a sticker.

This is the same philosophy as the crop-and-stitch pattern that's become the community default for region edits: never pass unchanged pixels through a VAE, composite only what you actually changed. Here it's grid-shaped and manual - you decide which tiles deserve a redo.

Feeding it is two wires and a choice. Connect 基底原图 (the base image - the slicer's 原图 output or your original upstream) and 切片数据 (the slicer's coordinate JSON, verbatim; the input's tooltip is explicit about which port to use). Then say which tiles you changed:

  • Direct slots: 块1_图片块30_图片, mapped by index - wire your edited 块5_图片 result into 块5_图片 and it replaces tile 5. No per-slot target numbering to set; the port number is the tile number.
  • 批次替换图片 + 批次对应块序号 - for many tiles at once. The order field is a small parser in its own right: "5", "2, 5, 8", "1-3, 5" (ranges and lists), or "全部". Images land on the listed tiles in sequence.

The two settings that decide quality:

  • 边缘羽化像素 (feather) - the blend width in pixels; 0 is a hard edge. The tooltip's recommendation of 12–32 matches the community's mask-blur wisdom: too little shows seams, too much bleeds the patch into its neighbors. The feather is a cosine S-curve applied only on seams that touch another tile - edges sitting on the image's outer border stay crisp, so you don't get a faint halo around the whole reassembled image.
  • 分辨率处理模式 (resolution mode) - three behaviors. Default scale the replacement back to the original slice size (keeps base resolution - right for a same-size inpaint). The standout is upscale the whole canvas proportionally to the highest tile magnification: if one tile came back 2× or 4× from a super-resolution pass, the entire composite grows to match and your upscaled detail survives instead of being shrunk away. Third is force-stretch the tile to fit regardless of aspect.

What you get back. Three outputs:

  • 还原后图像 - the assembled image (IMAGE).
  • 替换区域遮罩 - a MASK marking exactly the composited regions, which is genuinely useful if you want a follow-up pass to only touch where you just edited.
  • 还原汇总信息 - a STRING report listing each replacement's coordinates, resolution handling, and which tiles were left untouched. Nice for audits of batch work.

It's also defensive where pasting gets ugly: RGBA replacements have their alpha channel multiplied into the blend (so a tile from a transparent/outpaint pipeline doesn't leave hard edges), and channel/RGB-RGBA mismatches are reconciled rather than crashing.

Honest caveats. No 切片数据 means an error string out the summary port - connect it before anything else. And it's index-based: if you slice with a different cut layout than the data describes, tiles land on the wrong coordinates, so keep the reassembler fed from the same slicer run (or its 原图/切片数据 pair) that produced the tiles.

Install

Part of pongjoo/ComfyUI-PJLatent (MIT). ComfyUI Manager → search "ComfyUI-PJLatent", or:

cd ComfyUI/custom_nodes/
git clone https://github.com/pongjoo/ComfyUI-PJLatent.git

Restart ComfyUI - pure torch/PIL, no models or extra deps. Look for PJ 图像切片原位还原器 under "PJ_Nodes/Image".

CategoryPJ_Nodes/Image

Inputs (36)

NameTypeDefaultDescription
边缘羽化像素INT160–256切块与周围图像拼接边缘的渐变羽化宽度(像素)。0为硬边缘直接贴入,建议12~32消除缝隙接痕
分辨率处理模式COMBO缩放替换块至原切片尺寸 (维持基底分辨率)3 options: 缩放替换块至原切片尺寸 (维持基底分辨率), 整图等比高清放大 (自适应替换块最高倍率), 强制拉伸切片区域
基底原图optIMAGE
切片数据optSTRING请连接 PJ 图像交互式智能分割器 的【切片数据】输出端口
批次替换图片optIMAGE
批次对应块序号optSTRING指定批次替换图片对应的原图切块序号,如 '5'、'2,5,8'、'1-3,5' 或 '全部'。图片将按顺序对号入座
块1_图片optIMAGE
块2_图片optIMAGE
块3_图片optIMAGE
块4_图片optIMAGE
块5_图片optIMAGE
块6_图片optIMAGE
块7_图片optIMAGE
块8_图片optIMAGE
块9_图片optIMAGE
块10_图片optIMAGE
块11_图片optIMAGE
块12_图片optIMAGE
块13_图片optIMAGE
块14_图片optIMAGE
块15_图片optIMAGE
块16_图片optIMAGE
块17_图片optIMAGE
块18_图片optIMAGE
块19_图片optIMAGE
块20_图片optIMAGE
块21_图片optIMAGE
块22_图片optIMAGE
块23_图片optIMAGE
块24_图片optIMAGE
块25_图片optIMAGE
块26_图片optIMAGE
块27_图片optIMAGE
块28_图片optIMAGE
块29_图片optIMAGE
块30_图片optIMAGE

Outputs (3)

NameTypeDescription
还原后图像IMAGE
替换区域遮罩MASK
还原汇总信息STRING