fix: aggressively clear protected draft dark residue
This commit is contained in:
parent
729ccec2f8
commit
20693db8b9
@ -2657,31 +2657,49 @@ function suppressScaleAdjustProtectedFurnitureDarkAlpha(params: {
|
||||
return sourceY >= sourceBox.height * 0.3;
|
||||
};
|
||||
|
||||
let clearedPixels = 0;
|
||||
let markedPixels = 0;
|
||||
for (let localY = 0; localY < bbox.height; localY += 1) {
|
||||
for (let localX = 0; localX < bbox.width; localX += 1) {
|
||||
const alphaIndex = localY * bbox.width + localX;
|
||||
const alpha = output[alphaIndex] || 0;
|
||||
if (alpha === 0) continue;
|
||||
markedPixels += 1;
|
||||
|
||||
const colorIndex = alphaIndex * 3;
|
||||
const r = rawRgb[colorIndex] || 0;
|
||||
const g = rawRgb[colorIndex + 1] || 0;
|
||||
const b = rawRgb[colorIndex + 2] || 0;
|
||||
const { luma, saturation } = getScaleAdjustPixelStats(r, g, b);
|
||||
const veryDark = luma < 72;
|
||||
const flatDark = luma < 110 && saturation < 0.28;
|
||||
if (!veryDark && !flatDark) continue;
|
||||
|
||||
const sourceX = bbox.left + localX;
|
||||
const sourceY = bbox.top + localY;
|
||||
if (isProtectedSideArea(sourceX, sourceY)) {
|
||||
output[alphaIndex] = 0;
|
||||
} else {
|
||||
output[alphaIndex] = 0;
|
||||
}
|
||||
const inProtectedSideArea = isProtectedSideArea(sourceX, sourceY);
|
||||
const neutralDark =
|
||||
luma < 150 &&
|
||||
(saturation < 0.55 || (r < 110 && g < 110 && b < 110));
|
||||
const lowContrastDark = luma < 132 && saturation < 0.32;
|
||||
const shouldClear = inProtectedSideArea
|
||||
? neutralDark || lowContrastDark
|
||||
: luma < 100 || (luma < 132 && saturation < 0.22);
|
||||
if (!shouldClear) continue;
|
||||
|
||||
output[alphaIndex] = 0;
|
||||
clearedPixels += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (markedPixels > 0) {
|
||||
console.info(
|
||||
"[Canvas Local Edit] Scale adjust protected furniture dark alpha cleared:",
|
||||
{
|
||||
clearedRatio: Number((clearedPixels / markedPixels).toFixed(3)),
|
||||
clearedPixels,
|
||||
protectedPersonSide,
|
||||
totalMarkedPixels: markedPixels,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -4934,7 +4952,7 @@ export async function POST(request: NextRequest) {
|
||||
scaleAdjustPromptStrategy: isScaleAdjustOperation
|
||||
? scaleAdjustPatchReference
|
||||
? useScaleAdjustFullFrameStructurePatch
|
||||
? "full-frame-structure-locked-draft-v5-protected-side-dark-cleared-one-shot"
|
||||
? "full-frame-structure-locked-draft-v6-protected-side-dark-cleared-one-shot"
|
||||
: scaleAdjustPatchReference.structureLockedDraft
|
||||
? "ai-patch-workspace-structure-locked-draft-v87-subject-alpha-clipped-one-shot"
|
||||
: "ai-patch-workspace-draft-v75-soft-wipe-erase-ghost-one-shot"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user