convert image to number

hi everybody,
i want to convert image to number.
any suggestions.
thanks.
Can you explain a bit more?

Aceix.
i want read the image and to convert a pixels color to a number.
thanks
how to read image in c++?
The easiest thing would be to google some image libraries. You could also just learn about the file format and then read it in binary mode.

By the way, a colour is just a number in the first place.
i want a 'sample code simple' ,which to read image in c++.
thanks.
Last edited on
If it's png, jpeg, or tiff, you could do it with boost, too: http://www.boost.org/doc/libs/release/libs/gil/doc/html/group___i_o.html
now,how i can to convert image to set of numerics?
thanks.
Assuming by "set of numbers" you're referring to color components of individual pixels (per earlier comment), it depends on the library you're using.

With boost, it could be something like that:

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
#include <boost/gil/image_view.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
namespace gil = boost::gil;

void f(gil::rgb8_pixel_t px)
{
    std::cout << std::hex << std::showbase
              << '(' << +(uint8_t)px[0]
              << ',' << +(uint8_t)px[1]
              << ',' << +(uint8_t)px[2] << ')' << std::dec;
}
int main()
{
    gil::rgb8_image_t img;
    png_read_image("test.png", img);
    auto v = const_view(img);

    std::cout << "Top left pixel: ";
    f(v(0,0));
    std::cout << '\n';

    std::cout << "next five pixels: ";
    for_each_pixel(subimage_view(v, 1, 0, 1, 5), f);
    std::cout << '\n';
}
Does this mean to convert image to byte ,chech it out .http://www.rasteredge.com/how-to/csharp-imaging/covert-image-to-byte/
hi,
but i want to write program in c++.
Boost is a library for C++.
Topic archived. No new replies allowed.