62 lines
2.6 KiB
PowerShell
62 lines
2.6 KiB
PowerShell
param(
|
|
[string]$OutputPng = (Join-Path $PSScriptRoot '..\public\assets\sample-pet-depth.png'),
|
|
[string]$OutputJson = (Join-Path $PSScriptRoot '..\public\assets\sample-pet-depth.json')
|
|
)
|
|
|
|
# Hand-authored procedural fixture for local parallax tests.
|
|
# Depth convention: 0 = far/background, 1 = near/foreground.
|
|
# These values are visual approximations, not AI estimates or measurements.
|
|
Add-Type -AssemblyName System.Drawing
|
|
|
|
$width = 415
|
|
$height = 739
|
|
$background = 0.08
|
|
|
|
$landmarks = @(
|
|
[pscustomobject]@{ name = 'nose'; x = 235; y = 310; depth = 0.98; rx = 23; ry = 18 },
|
|
[pscustomobject]@{ name = 'left-eye'; x = 198; y = 278; depth = 0.68; rx = 27; ry = 21 },
|
|
[pscustomobject]@{ name = 'right-eye'; x = 249; y = 273; depth = 0.68; rx = 27; ry = 21 },
|
|
[pscustomobject]@{ name = 'face'; x = 221; y = 267; depth = 0.60; rx = 91; ry = 78 },
|
|
[pscustomobject]@{ name = 'left-ear'; x = 158; y = 213; depth = 0.43; rx = 66; ry = 91 },
|
|
[pscustomobject]@{ name = 'right-ear'; x = 262; y = 206; depth = 0.43; rx = 69; ry = 96 },
|
|
[pscustomobject]@{ name = 'body'; x = 139; y = 419; depth = 0.30; rx = 139; ry = 238 },
|
|
[pscustomobject]@{ name = 'muzzle'; x = 224; y = 305; depth = 0.82; rx = 58; ry = 43 }
|
|
)
|
|
|
|
$bitmap = [System.Drawing.Bitmap]::new($width, $height, [System.Drawing.Imaging.PixelFormat]::Format24bppRgb)
|
|
try {
|
|
for ($y = 0; $y -lt $height; $y++) {
|
|
for ($x = 0; $x -lt $width; $x++) {
|
|
$value = $background
|
|
foreach ($shape in $landmarks) {
|
|
$dx = ($x - $shape.x) / [double]$shape.rx
|
|
$dy = ($y - $shape.y) / [double]$shape.ry
|
|
$gaussian = [Math]::Exp(-0.5 * ($dx * $dx + $dy * $dy))
|
|
# Max-combine softly feathered ellipses so overlaps keep the nearer layer.
|
|
$candidate = $background + ($shape.depth - $background) * $gaussian
|
|
if ($candidate -gt $value) { $value = $candidate }
|
|
}
|
|
$byte = [int][Math]::Round([Math]::Min(1.0, [Math]::Max(0.0, $value)) * 255.0)
|
|
$color = [System.Drawing.Color]::FromArgb($byte, $byte, $byte)
|
|
$bitmap.SetPixel($x, $y, $color)
|
|
}
|
|
}
|
|
$bitmap.Save($OutputPng, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
}
|
|
finally {
|
|
$bitmap.Dispose()
|
|
}
|
|
|
|
$metadata = [ordered]@{
|
|
width = $width
|
|
height = $height
|
|
convention = '0 = far/background, 1 = near/foreground'
|
|
source = 'Hand-authored procedural Gaussian ellipses for local testing; not AI-estimated or physically measured.'
|
|
landmarks = @($landmarks | ForEach-Object {
|
|
[ordered]@{ name = $_.name; x = $_.x; y = $_.y; depth = $_.depth }
|
|
})
|
|
}
|
|
$metadata | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath $OutputJson -Encoding utf8
|
|
Write-Output "Created $OutputPng"
|
|
Write-Output "Created $OutputJson"
|