size of recoverd image gets increased [closed]
I am reading image from this method
Mat originalImage = Highgui.imread(path);
byte[] imageInByte = new byte[(int) (originalImage.total() * originalImage.channels())];
originalImage.get(0, 0, imageInByte);
TYPE = originalImage.type();
HEIGHT = originalImage.height();
WIDTH = originalImage.width();
while recovering image i'm using
Mat mat = new Mat(HEIGHT, WIDTH , TYPE);
mat.put(0, 0, bytesArrayForImage);
String filename = Path;
Highgui.imwrite(filename, mat);
by using these 2 methods i'm getting image of large size and the difference in between these 2 images which i'm getting is only bit depth i'm not getting how to resolve it
which opencv version is it ?
can you edit it a bit, so the code compiles / can be reproduced ?
(i also cannot reproduce it, using 3.4.1 / 4.0.0)
i'm using 3.4.0 version of opencv
oh, wait, did you mean the size on disk ? (not W/H ?)
this entirely depends on file type and compression params passed to imwrite()
yes size on disk gets double and in properties of my file byte depths also gets increased by 3 times
bit depth of original image is 8 and reconstructed image's bit depth is 24
Highgui.imread(path);
<-- this is from opencv2.4, not 3.4 and it will force reading in a 24bit image.to read a grayscale one use
(if you're using outdated 2.4), for 3.x it would be:
please check again. it would be Imgcodecs, not Highgui, then.
It is Highgui, because when i'm tried with Imgcodecs it gives error
so it's 2.4, not 3.4.0.
however it will behave the same. if you want to read in a grayscale image, use the
CV_LOAD_IMAGE_GRAYSCALE
flag ( IMREAD_GRAYSCALE for 3.x)its woring thanks