feat: Temporal-dependent packing stub

This commit is contained in:
Leni Aniva 2025-04-10 15:23:06 -07:00
parent a0fe1e843a
commit e468e60fc5
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 47 additions and 0 deletions

8
src/image.jl Normal file
View File

@ -0,0 +1,8 @@
using Images
"""
Converts image to grayscale
"""
function greyscale(c::Images.RGB)::UInt8
return c.r
end

39
src/tdpacking.jl Normal file
View File

@ -0,0 +1,39 @@
# Time-dependent packing
struct Rect
pos::Tuple{UInt,UInt}
size::Tuple{UInt,UInt}
color::Real
end
"""
divide_image(img::BitMatrix, size_min::UInt=16, size_max::UInt=256)
Divides an image into rectangles of the same colour. The rectangles are not
allowed to have extreme aspect ratios. There is a minimal size of each retangle.
"""
function divide_image(img::Matrix{}, size_min::UInt=16, size_max::UInt=256)::Array{Rect}
result = Rect[]
# Remaining area
area = sizeof(img)
# Loop until the entire field is filled
while area > 0
pos = (9, 9)
size = (threshold, threshold)
region = img.size
# Try to expand this rectangle to the maximum size
while size[1] < region[1] || size[2] < region[2]
end
color = 0.5
push!(result, Rect(pos, size, color))
# Update the boundary markers for the next iteration
area -= size[1] * size[2]
end
return result
end