Distorted size of image obtained after construction from byte value? [closed]
I am using
Mat img = new Mat(440, 442, CvType.CV_8UC1); img.put(0, 0, bytearray);
To construct back a grayscale image of 440*442 dimension after performing few conversion function on its pixel value.The obtained image has a change in its bit Depth which is 24 in the original image and 8 in the constructed image. The reconstructed image is below:::::::
The original image:::::::
"The obtained image has a change in its bit Depth which is 24 in the original image and 8 in the constructed image." -- you'll have to explain that.
i had a look into image properties details in which both the images has same high and width but the bit depth value is different .
the original image looks like grayscale, but is bgr, so you have to adjust your flags / processing there.
but we cannot help, until we see, what you're doing with it, and what assumptions about it are in your code
I am extracting 8 bit binary value of each pixel and then applying random bit function to it and then changing it to byte array to reconstruct the image
maybe you should use opencv functions all the way down, not insist on manually working on byte arrays
and again, if your input img has 3 channels, you'll have to adapt your algirithm, and the output type (or convert it to single channel before)
Can you give me an example as to how to make 3 channel conversion to single channel?
cvtColor(src,dst,COLOR_BGR2GRAY)
Now the image has changed into 8 bit depth still the same image is reconstructed.. Also when i am using Highgui.imdecode(new MatOfByte(original_pixels),Highgui.IMREAD_GRAYSCALE ) the original image is constructed perfectly from the unaltered pixel value but when applied to altered pixel value it doesn't work and gives error.
again, there is a big, black information hole around your processing, the need of byte arrays, etc.
please understand, that we cannot help with what we cannot see..
//1. Convert Image to byte code ImgDemo im = new ImgDemo(); String path = "C:\Users\domin\Desktop\Sop\peppers.png"; byte[] aa = im.ByteConvert(path); //System.out.println(Arrays.toString(aa));
After the 4th step the array of bytes that i get is the one i am tryng to convert to image