per-element max of channel 1 with copy of channel 2 ? (java)
I need to implement something like this:
- do a per-element max() for two matrices a, b into a result matrix c [that is: c[i]=max(a[i],b[i])]
- remember (separately for each element) if a or b provided the max value (in a second channel of c or in a new matrix d) (this is the interesting part for me)
Is there a good way to use opencv functionality for this? (NB: I'll implement in java, but I guess my question is language-independent.)
" per-element max() for two not-equal-sized matrices a, b" -- does not make any sense (at least not without further explanation)
@berak It does not? :) Let's say: a and b are padded to equal size before. Or I redefine:
but I thought that would have made the question more complicate than it needed to be!? Anyway, the tricky part is the second one (remembering if the value originated from a or b), isn't it? For that one especially I'd very much like a pointer to a possible and efficient solution! (Of course I could code that in pure Java. That would work but presumably quite slow.)
no, it does not. if the images don't have the same size,
i
in one image does not refer to the same position, as in another image, and you're comparing apples to pears.again, WHY? (we're still waiting for an explanation)
there are matrix operations for all of this, but you have to solve this problem, before.
maybe the problem is your single index , while images are 2d ? and sure, there are submats and padding to solve it.
I edited the question to make it more readable. (@berak)
max and compare is all you need.
and how comes, that i am reading the docs, while you don't ? (that's the really silly part here)