fix: accept visible scale shrink footprints
This commit is contained in:
parent
c4e4981a24
commit
2ca0c54de2
@ -185,6 +185,8 @@ const SCALE_ADJUST_FALLBACK_MASK_DISTANCE_THRESHOLD = 42;
|
|||||||
const SCALE_ADJUST_FALLBACK_MASK_LUMA_GAP = 18;
|
const SCALE_ADJUST_FALLBACK_MASK_LUMA_GAP = 18;
|
||||||
const SCALE_ADJUST_FALLBACK_INPAINT_ITERATIONS = 180;
|
const SCALE_ADJUST_FALLBACK_INPAINT_ITERATIONS = 180;
|
||||||
const SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MAX_RATIO = 0.72;
|
const SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MAX_RATIO = 0.72;
|
||||||
|
const SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_RELAXED_MAX_RATIO = 0.84;
|
||||||
|
const SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MIN_REMOVED_RATIO = 0.14;
|
||||||
const SCALE_ADJUST_SHRINK_MIN_SOURCE_OUTSIDE_PIXELS = 60;
|
const SCALE_ADJUST_SHRINK_MIN_SOURCE_OUTSIDE_PIXELS = 60;
|
||||||
const SCALE_ADJUST_SHRINK_TARGET_FOOTPRINT_MARGIN = 0.018;
|
const SCALE_ADJUST_SHRINK_TARGET_FOOTPRINT_MARGIN = 0.018;
|
||||||
|
|
||||||
@ -894,7 +896,10 @@ async function getScaleAdjustFootprintChangeStats(params: {
|
|||||||
generatedOutsidePixels: number;
|
generatedOutsidePixels: number;
|
||||||
outsideRatio: number;
|
outsideRatio: number;
|
||||||
passed: boolean;
|
passed: boolean;
|
||||||
|
passReason: "low-source-mask" | "strict-ratio" | "removed-old-footprint" | "failed";
|
||||||
regionIndex: number;
|
regionIndex: number;
|
||||||
|
removedOutsidePixels: number;
|
||||||
|
removedOutsideRatio: number;
|
||||||
sourceOutsidePixels: number;
|
sourceOutsidePixels: number;
|
||||||
}> = [];
|
}> = [];
|
||||||
|
|
||||||
@ -952,14 +957,37 @@ async function getScaleAdjustFootprintChangeStats(params: {
|
|||||||
}
|
}
|
||||||
const outsideRatio =
|
const outsideRatio =
|
||||||
sourceOutsidePixels > 0 ? generatedOutsidePixels / sourceOutsidePixels : 0;
|
sourceOutsidePixels > 0 ? generatedOutsidePixels / sourceOutsidePixels : 0;
|
||||||
const passed =
|
const removedOutsidePixels = sourceOutsidePixels - generatedOutsidePixels;
|
||||||
sourceOutsidePixels < SCALE_ADJUST_SHRINK_MIN_SOURCE_OUTSIDE_PIXELS ||
|
const removedOutsideRatio =
|
||||||
|
sourceOutsidePixels > 0 ? removedOutsidePixels / sourceOutsidePixels : 0;
|
||||||
|
const minRemovedOutsidePixels = Math.max(
|
||||||
|
SCALE_ADJUST_SHRINK_MIN_SOURCE_OUTSIDE_PIXELS,
|
||||||
|
Math.round(
|
||||||
|
sourceOutsidePixels * SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MIN_REMOVED_RATIO
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const lowSourceMask =
|
||||||
|
sourceOutsidePixels < SCALE_ADJUST_SHRINK_MIN_SOURCE_OUTSIDE_PIXELS;
|
||||||
|
const strictRatio =
|
||||||
outsideRatio <= SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MAX_RATIO;
|
outsideRatio <= SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_MAX_RATIO;
|
||||||
|
const removedOldFootprint =
|
||||||
|
outsideRatio <= SCALE_ADJUST_SHRINK_OUTSIDE_FOOTPRINT_RELAXED_MAX_RATIO &&
|
||||||
|
removedOutsidePixels >= minRemovedOutsidePixels;
|
||||||
|
const passed = lowSourceMask || strictRatio || removedOldFootprint;
|
||||||
shrinkStats.push({
|
shrinkStats.push({
|
||||||
generatedOutsidePixels,
|
generatedOutsidePixels,
|
||||||
outsideRatio,
|
outsideRatio,
|
||||||
passed,
|
passed,
|
||||||
|
passReason: lowSourceMask
|
||||||
|
? "low-source-mask"
|
||||||
|
: strictRatio
|
||||||
|
? "strict-ratio"
|
||||||
|
: removedOldFootprint
|
||||||
|
? "removed-old-footprint"
|
||||||
|
: "failed",
|
||||||
regionIndex: index,
|
regionIndex: index,
|
||||||
|
removedOutsidePixels,
|
||||||
|
removedOutsideRatio,
|
||||||
sourceOutsidePixels,
|
sourceOutsidePixels,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1270,7 +1298,10 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
generatedOutsidePixels: item.generatedOutsidePixels,
|
generatedOutsidePixels: item.generatedOutsidePixels,
|
||||||
outsideRatio: Number(item.outsideRatio.toFixed(3)),
|
outsideRatio: Number(item.outsideRatio.toFixed(3)),
|
||||||
passed: item.passed,
|
passed: item.passed,
|
||||||
|
passReason: item.passReason,
|
||||||
regionIndex: item.regionIndex,
|
regionIndex: item.regionIndex,
|
||||||
|
removedOutsidePixels: item.removedOutsidePixels,
|
||||||
|
removedOutsideRatio: Number(item.removedOutsideRatio.toFixed(3)),
|
||||||
sourceOutsidePixels: item.sourceOutsidePixels,
|
sourceOutsidePixels: item.sourceOutsidePixels,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
@ -1312,7 +1343,10 @@ async function applyScaleAdjustVerificationToImages(params: {
|
|||||||
generatedOutsidePixels: item.generatedOutsidePixels,
|
generatedOutsidePixels: item.generatedOutsidePixels,
|
||||||
outsideRatio: Number(item.outsideRatio.toFixed(3)),
|
outsideRatio: Number(item.outsideRatio.toFixed(3)),
|
||||||
passed: item.passed,
|
passed: item.passed,
|
||||||
|
passReason: item.passReason,
|
||||||
regionIndex: item.regionIndex,
|
regionIndex: item.regionIndex,
|
||||||
|
removedOutsidePixels: item.removedOutsidePixels,
|
||||||
|
removedOutsideRatio: Number(item.removedOutsideRatio.toFixed(3)),
|
||||||
sourceOutsidePixels: item.sourceOutsidePixels,
|
sourceOutsidePixels: item.sourceOutsidePixels,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user