c++ - Isn't BMP in opencv lossless? -


i using opencv c++ test gray images bmp format.

here code sample:

mat img_cv = imread("test.jpg"); imwrite("aaa.bmp", img_cv); mat img_cv2 = imread("aaa.bmp") 

since bmp format lossless img_cv , img_cv2 should same, aren't. here output sample, 10x10 gray image;

img_cv:

41 41 41 64 64 64 47 47 47 42 29 29 29 36 36 36 60 60 60 57 68 68 68 52 52 52 61 61 61 228 42 42 42 33 33 33 160 160 160 229 47 47 47 68 68 68 128 128 128 171 38 38 38 50 50 50 97 97 97 70 67 67 67 67 67 67 66 66 66 104 104 104 104 105 105 105 99 99 99 95 95 95 95 115 115 115 115 115 115 113 74 74 74 74 74 74 90 90 90 115 

img_cv2

41 64 47 42 55 76 197 177 54 62 29 36 60 57 200 248 246 240 160 51 68 52 61 228 248 247 248 242 158 48 42 33 160 229 237 240 244 194 62 43 47 68 128 171 96 113 77 74 66 55 38 50 97 70 98 64 88 69 71 40 67 67 66 104 87 102 98 76 56 57 104 105 99 95 92 107 85 87 60 51 95 115 115 113 109 103 112 99 57 63 74 74 90 115 119 113 124 92 51 47 

so doing wrong or missing when dealing bmp format?

you're misinterpreting binary data of bitmaps. source bitmap 24 bits per pixel, whereas new bitmap 8 bits per pixel. notice how on source, each value repeated 3 times. (3 times 8 bit bytes = 24 bits) if combine each set of 3 bytes single byte, matches target bitmap. appear truncating 1/3 of binary data in source bitmap posted.

so translation lossless only if source greyscale. if opencv indeed implicitly converting 24bpp 8bpp, lossless operation.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -