how to get Mod 256 of image using opencv in java
I am completely new user about opencv can anyone please suggest me how to take mod 256 of image using opencv in java
I am completely new user about opencv can anyone please suggest me how to take mod 256 of image using opencv in java
there is no such builtin operation. (opencv will rather saturate pixels for builtin additions/subtractions and such.)
so (assuming a single channel uchar image) you'll have to:
// 1. get to the pixels:
byte bytes = new bytes[img.total()];
img.get(0,0,bytes); // copy.
// 2. java's byte type is *signed*, [-127,+127]
// so you have to cast every single one to an integer, before you can do maths on it
// ex.
int A = 0x7f + (int)bytes[i]; // to [0..255] range
int B = 200; // some number from your algorithm
int C = (A + B) % 256; // here's the modulo !
byte result = (byte)(C - 0x7f); // convert back
bytes[i] = result;
// 3. write back the pixels:
img.put(0,0,bytes);
as you can see, it's all very clumsy. neither opencv, nor java are a good choice for this.
Asked: 2018-06-24 07:33:54 -0600
Seen: 336 times
Last updated: Jun 24 '18
Hi, m trying to display image(mat) on windows but i am getting black imageicon
Convert MatOfKeyPoint to bytes[] and converse
Check if two images are similarity or not.
OpenCV similarity between two images using Euclidean distance
opencv_xx.jar not found [closed]
unable to compile java opencv file [closed]
running java class issue [closed]
what are you trying to achieve ? what do you need it for ?
i'm trying to encrypt image using some specific algorithm so i need to find out mod 256 of image
are you sure, that opencv is the right library for you ?
and it's still unclear, what exactly you're trying to do. do you have a formula, or similar ?
yes, i think opencv is more better for me
again, please try to explain what your assigment is about in more detail, else we cannot help you.
( mod 256 of image ) on it's own does not make any sense.
i want to generate shares of image using additive modulo