Home Opencv Grayscale images
Reply: 1

Opencv Grayscale images

Chameera Subasinghe
Chameera Subasinghe Published in 2018-01-11 06:47:42Z
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {

This returns a mat. If i convert this to a byte array the maximum is 127 and minimum is -128. I want to convert this to min 0 and max 255. Is this possible???

If so how? I tried to write a for loop and added 128 to each element in byte array. Though it causes the byte array to have min of -105 and max of 107.

Any ideas??

for(int k=0;k<grayScaleImageArray.length;++k){
        grayScaleImageArray[k]= (byte) (grayScaleImageArray[k]+128);
NewTech Reply to 2018-01-12 08:01:54Z

As Micka stated in the comments, you have to use a different typ i.e. 8 bit unsigned.

uchar[] unsignedArray = new uchar[signedArray.length];
for(int k = 0; k < signedArray.length; ++k)
  unsignedArray[k] = uchar((int)(signedArray[k]) + 128);
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.298294 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO