fix: filter scale adjust haze in patch composites

This commit is contained in:
134 2026-07-04 16:46:04 +08:00
parent 1a60671255
commit 40fa7b1e26
2 changed files with 28 additions and 6 deletions

View File

@ -4408,10 +4408,18 @@ export async function POST(request: NextRequest) {
referenceImages,
scaleAdjustPatchComposite: scaleAdjustPatchReference
? {
diffCompareBlurPx: 0.8,
diffHighThreshold: 42,
diffLowThreshold: 14,
featherMaxPx: 42,
diffAlphaCutoff:
scaleAdjustPatchReference.structureLockedDraft ? 24 : 8,
diffAlphaMultiplier:
scaleAdjustPatchReference.structureLockedDraft ? 2.25 : 3,
diffCompareBlurPx:
scaleAdjustPatchReference.structureLockedDraft ? 1.2 : 0.8,
diffHighThreshold:
scaleAdjustPatchReference.structureLockedDraft ? 72 : 42,
diffLowThreshold:
scaleAdjustPatchReference.structureLockedDraft ? 26 : 14,
featherMaxPx:
scaleAdjustPatchReference.structureLockedDraft ? 36 : 42,
featherMinPx: 10,
featherRatio: 0.018,
maskMode: "diff",

View File

@ -58,6 +58,8 @@ export interface CanvasScaleAdjustPatchCompositeConfig {
workspaceRegion: CanvasLocalEditCompositeRegion;
regions?: CanvasLocalEditCompositeRegion[];
maskMode?: "workspace" | "diff";
diffAlphaCutoff?: number;
diffAlphaMultiplier?: number;
diffLowThreshold?: number;
diffHighThreshold?: number;
diffCompareBlurPx?: number;
@ -405,6 +407,14 @@ function normalizeScaleAdjustPatchCompositeConfig(
workspaceRegion,
...(regions.length > 0 ? { regions } : {}),
maskMode: value.maskMode === "diff" ? "diff" : "workspace",
diffAlphaCutoff: normalizeOptionalNumber(value.diffAlphaCutoff, {
max: 96,
min: 0,
}),
diffAlphaMultiplier: normalizeOptionalNumber(value.diffAlphaMultiplier, {
max: 6,
min: 0.5,
}),
diffHighThreshold: normalizeOptionalNumber(value.diffHighThreshold, {
max: 120,
min: 1,
@ -2961,8 +2971,12 @@ async function applyScaleAdjustPatchCompositeToImages(params: {
regionClipPatchMaskRaw ||
Buffer.alloc(workspaceBox.width * workspaceBox.height, 255)
),
8,
3
typeof composite.diffAlphaCutoff === "number"
? composite.diffAlphaCutoff
: 8,
typeof composite.diffAlphaMultiplier === "number"
? composite.diffAlphaMultiplier
: 3
),
height: workspaceBox.height,
imageBuffer: resizedGeneratedBuffer,