Android Can i use setTo() with a Condition, just like in C/C++
Hi,
i am actually porting some code to Android, but i don't know, how i can translate this code :
myMat.setTo(0, otherMat < threshVal);
As i think, every value in the matrix - myMat is set to 0 when the value at the corresponding place in "otherMat" is lower than "threshVal" - right?
I would just use a for-loop to solve this, but i think there must be a better way - just as in the C-Code Version.
Also - how to translate this C-Code:
myMat = myMat / ( otherMat+1 );
Thank you for your help.
http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#threshold(org.opencv.core.Mat,%20org.opencv.core.Mat,%20double,%20double,%20int)
in any case, avoid for-loops(over the pixels) in java
i guess, that threshold does not work for me - all the threshold-types are checking for - src(x,y) > thresh - but i need - if (src(x,y) < thresh) then 0 otherwise dst(x,y).
or am i wrong?
it has a flag to invert it
so i now have:
Imgproc.threshold(otherMat, myMat, threshVal, 0, Imgproc.THRESH_TOZERO_INV);
where do i find that inverting-flag? or where do i put it in?
another question is that i ONLY want to set the value to 0 if the condition is fulfilled and leave the value alone when not - because that is, what the C-Code says , right?
http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#THRESH_BINARY_INV
"i ONLY want to set the value to 0 if the condition is fulfilled and leave the value alone when not" -
i already feared you would say this. yes alright a plain threshold does not do this exactly.
you probbaly generate a binary mask (using threshold) in this case, and supply it as additional input to to binary_and() or binary_or()
yea, damn, the java api does not know nifty operator overloading, you have to get creative here ..
alright - thats what i thought... :/
thank you for your help.
or maybe i am totally wrong - what exactly does " myMat.setTo(0, otherMat < threshVal); " do?