I have 2 bitmaps of exactly the same size and I want to find the smallest area of change between the two. Here's a Kotlin equivalent of what I am doing:
var minX = Int.MAX_VALUE
var minY = Int.MAX_VALUE
var maxX = 0
var maxY = 0
for (i in 0 until cols) {
for (j in 0 until rows) {
if (bitmapOne.getPixel(i, j) != bitmapTwo.getPixel(i, j)) {
if (i < minX) minX = i
if (i > maxX) maxX = i
if (j < minY) minY = j
if (j > maxY) maxY = j
}
}
}
All I need is the four points of rectangle holding the smallest area of change. Renderscript bitmap iterations are way faster based on some tests I did, so I am trying to learn Renderscript and port this Kotlin code too.
The issue I am facing is that I am unable to pass 2 bitmaps as allocations to any mapping kernel. The documentation says
"If you need more input or output Allocations than the kernel has, those objects should be bound to rs_allocation script globals and accessed from a kernel or invokable function via rsGetElementAt_type() or rsSetElementAt_type()."
But there are not enough examples around this.
The second issue is how to get a return type, since none of the kernels have a return type - the input/output allocation examples I see so far are all of same dimensions. But I need a different dimension as output (just an Int4).
On going through the reduce kernel documentation, it seems like they too can't process 2 allocations together.
I may be wrong in my understanding so far. Would appreciate any help which can get me started.