Majority Reduce
object MajorityReduce
Reduces a draft shaded at factor times the canvas to the canvas, one block of factor × factor pixels per final pixel, by vote. A block is figure when at least half of it is; it then takes the zone most of its figure pixels have, and the colour most of that zone's pixels in the block have, so zone and colour always agree. Ties go to the lowest label, the same way every time.
With the previous key frame's reduction and a hold, a block keeps what the previous frame had unless the vote moves clearly: coverage more than hold samples from the 50 % line, or another label more than hold samples above the previous one. That keeps a draft from flickering between key frames.
Functions
Link copied to clipboard
fun reduce(colours: IndexedRaster, zones: IndexedRaster, factor: Int, previous: Draft? = null, hold: Int = 0): Draft