i want to generate a gray-scale image from byte array,is it possible to do it with opencv ?
I am using java to read an image and to generate its byte array on which few functions are performed ,now i want to obtain an image from this altered bytes.Is it possible in opencv.
sure that is possible, but you have to tell us, where your byte array comes from, and what is in it.
I have taken a gray-scale image and have read it using java .then have taken 8 bits for each pixel of the image.further on each of this pixel i have performed various functions in the end i have again taken the decimal value of this pixels in attempt to regenerate the image.But so far i am unsuccessful,so now how can i read the pixel value obtained to again reconstruct the image of same height and width. i am getting something like this[43 25 29 13 0 12 48 60 21 29 4 31 27 3 35 54 17 49 12 1 22 24 ]
not enough information. width ? height ? channels ? how long is you array ?
The image that i am getting using your solution is a noisy image.The input image i am taking is lena.png 256*256 grayscale image.I am not changing the pixels just trying to regenerate it.
//2. Convert byte to image Mat img1 = new Mat(256,256, CvType.CV_8UC1);
@Ann162 , and ? what are you trying to say ?
also, why not simply use imread() to read the image ?
imread doesnot return the byte array of the image,which is required for further processing.