forked from jakubo87/OCRe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjpegimportGIL.cc
More file actions
38 lines (29 loc) · 1.16 KB
/
Copy pathjpegimportGIL.cc
File metadata and controls
38 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//source https://www.quora.com/How-can-we-convert-a-png-jpeg-image-into-a-2D-array-in-C++-If-possible-please-attach-code-snippets
#include <iostream>
#include <boost/gil/extension/io/jpeg_io.hpp>
// #include <boost/gil/gil_all.hpp>
namespace gil = boost::gil;
int main()
{
/*
gil::rgb8_image_t img;
gil::jpeg_read_image("demo.jpg", img);
std::cout << "Read complete, got an image " << img.width()
<< " by " << img.height() << " pixels\n";
gil::rgb8_pixel_t px = *const_view(img).at(5, 10);
std::cout << "The pixel at 5,10 is "
<< (int)px[0] << ','
<< (int)px[1] << ','
<< (int)px[2] << '\n';
*/
//#####
//std::cout << "anfd now the same as greyscale:\n";
gil::gray8_image_t img2;
gil::jpeg_read_image("Testimages/7007.jpg", img2);
std::cout << "Read complete, got an image " << img2.width()
<< " by " << img2.height() << " pixels\n";
gil::gray8_pixel_t px2 = *const_view(img2).at(5, 10);
std::cout << "The pixel at 5,10 is "
<< (int)px2[0] << '\n';
}
//fucking include -ljpeg at compiler bitch!