fix: ignore top background sheets in scale masks

This commit is contained in:
134 2026-07-03 22:07:46 +08:00
parent bb78cb5d4a
commit 026164f86d

View File

@ -1425,8 +1425,16 @@ function filterScaleAdjustStructureComponents(params: {
const componentBoxArea = Math.max(1, componentWidth * componentHeight);
const componentDensity = area / componentBoxArea;
const centerXRatio = (minX + componentWidth / 2) / width;
const centerYRatio = (minY + componentHeight / 2) / height;
const touchesTop = minY <= height * 0.04;
const touchesRight = maxX >= width * 0.88;
const edgeSliver = touchesRight && componentWidth < width * 0.18;
const broadTopBackground =
touchesTop &&
centerYRatio <= 0.45 &&
componentWidth >= width * 0.42 &&
componentHeight >= height * 0.18 &&
componentDensity >= 0.18;
const elongated =
componentHeight > componentWidth * 2.4 ||
componentWidth > componentHeight * 2.4;
@ -1442,7 +1450,12 @@ function filterScaleAdjustStructureComponents(params: {
componentDensity >= 0.035 &&
componentDensity <= 0.72;
if (likelyStructure && centeredEnough && !edgeSliver) {
if (
likelyStructure &&
centeredEnough &&
!edgeSliver &&
!broadTopBackground
) {
if (fillSurfaceComponent) {
for (let fillY = minY; fillY <= maxY; fillY += 1) {
for (let fillX = minX; fillX <= maxX; fillX += 1) {