fix: clean product lock masks before scale adjust overlay
This commit is contained in:
parent
6694846c58
commit
7640e6b5ca
@ -1944,8 +1944,9 @@ function filterScaleAdjustStructureComponents(params: {
|
||||
function solidifyScaleAdjustStructureMask(params: {
|
||||
box: { width: number; height: number };
|
||||
mask: Uint8Array;
|
||||
maxPanelSpanRatio?: number;
|
||||
}) {
|
||||
const { box, mask } = params;
|
||||
const { box, mask, maxPanelSpanRatio = 0.86 } = params;
|
||||
const width = box.width;
|
||||
const height = box.height;
|
||||
const bridgeGap = Math.max(2, Math.round(Math.min(width, height) * 0.006));
|
||||
@ -2033,7 +2034,7 @@ function solidifyScaleAdjustStructureMask(params: {
|
||||
const density = marked / Math.max(1, span * bandHeight);
|
||||
if (
|
||||
span < width * 0.16 ||
|
||||
span > width * 0.86 ||
|
||||
span > width * maxPanelSpanRatio ||
|
||||
density < 0.025 ||
|
||||
density > 0.78
|
||||
) {
|
||||
@ -2535,6 +2536,14 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
}),
|
||||
})
|
||||
: null;
|
||||
const protectedPersonRemovalMask =
|
||||
protectedPersonMask ||
|
||||
(protectedPersonSide && sameSizeCutout
|
||||
? buildScaleAdjustProtectedPersonGeometryMask({
|
||||
box: { width: cutoutWidth, height: cutoutHeight },
|
||||
side: protectedPersonSide,
|
||||
})
|
||||
: null);
|
||||
const sideProtectedCleanedAlpha =
|
||||
protectedPersonSide && sameSizeCutout && sourceCropRaw
|
||||
? suppressScaleAdjustProtectedFurnitureDarkAlpha({
|
||||
@ -2548,7 +2557,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
: cleanedAlpha;
|
||||
const protectedCleanedAlpha = removeScaleAdjustMaskFromAlpha({
|
||||
alphaMask: sideProtectedCleanedAlpha,
|
||||
removeMask: protectedPersonMask,
|
||||
removeMask: protectedPersonRemovalMask,
|
||||
});
|
||||
for (let index = 0; index < protectedCleanedAlpha.length; index += 1) {
|
||||
cleanedRaw[index * 4 + 3] = protectedCleanedAlpha[index] || 0;
|
||||
@ -2644,6 +2653,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
? solidifyScaleAdjustStructureMask({
|
||||
box: placement.sourceBox,
|
||||
mask: filteredSourceMask,
|
||||
maxPanelSpanRatio: protectedPersonSide ? 0.96 : 0.9,
|
||||
})
|
||||
: highConfidenceSourceMask;
|
||||
const sourceWashMask = dilateScaleAdjustStructureMask({
|
||||
@ -2745,7 +2755,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
const targetClipMaskPatch =
|
||||
await buildScaleAdjustOverlayClipMaskPatch(structureOverlay);
|
||||
const productLockProtectMask =
|
||||
protectedPersonMask ||
|
||||
protectedPersonRemovalMask ||
|
||||
(protectedPersonSide
|
||||
? buildScaleAdjustProtectedPersonGeometryMask({
|
||||
box: placement.sourceBox,
|
||||
@ -2781,7 +2791,7 @@ async function buildScaleAdjustRmbgStructureLockedComposite(params: {
|
||||
placedWidth,
|
||||
protectedPersonSide,
|
||||
protectedPersonGeometryMaskApplied:
|
||||
Boolean(productLockProtectMask) && !protectedPersonMask,
|
||||
Boolean(protectedPersonRemovalMask) && !protectedPersonMask,
|
||||
protectedPersonMaskApplied: Boolean(protectedPersonMask),
|
||||
sameSizeCutout,
|
||||
alphaBandingStats,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user