[try Beta version]
Not logged in

 
convert image to number

May 15, 2013 at 7:28am
hi everybody,
i want to convert image to number.
any suggestions.
thanks.
May 15, 2013 at 8:09am
Can you explain a bit more?

Aceix.
May 15, 2013 at 6:49pm
i want read the image and to convert a pixels color to a number.
thanks
May 16, 2013 at 4:53am
how to read image in c++?
May 16, 2013 at 5:30am
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.
May 17, 2013 at 7:43pm
i want a 'sample code simple' ,which to read image in c++.
thanks.
Last edited on May 18, 2013 at 5:35am
May 17, 2013 at 8:49pm
May 17, 2013 at 10:25pm
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
May 18, 2013 at 7:29am
now,how i can to convert image to set of numerics?
thanks.
May 18, 2013 at 3:20pm
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';
}
Jun 4, 2013 at 9:51am
Does this mean to convert image to byte ,chech it out .http://www.rasteredge.com/how-to/csharp-imaging/covert-image-to-byte/
Jun 4, 2013 at 10:04am
hi,
but i want to write program in c++.
Jun 4, 2013 at 11:15am
Boost is a library for C++.
Topic archived. No new replies allowed.