8

Can anyone indicate an example of how to do this? Link, tutorial etc... I started a discussion here about how to load a TIFF image like a graph nicely answered by @sehe. But, in this post the image is RGB. Then, after change for my needs(TIFF grayscale) the result is a image spatially displaced...

Real example of raster (was converted to PNG after upload) Grayscale with float pixel values and current CRS (Coordinate Reference System) is SIRGAS2000:

This is a example of raster clipped

From original code posted by @sehe I made some changes:

// I modified the type from rbg to grayscale
using Img = boost::gil::gray32f_image_t; 
using Px  = Img::value_type;
Img img;

boost::gil::tiff_read_and_convert_image("raster.tif", img);
auto vw = view(img);

Next, I modified this code:

        auto calc_color = [&](size_t v) {
        std::ostringstream oss;
        oss << std::hex << std::noshowbase << std::setfill('0');

        //I removed the from[1] and from[2] because is a graycale image
        auto const& from = pixel_sample(vertex(v, graph));
        oss << "#" << std::setw(2) << static_cast<int>(from[0]);

        return oss.str();
    };

Now, I am trying to use the boost functions:

  • Eager Dijkstra shortest paths
  • Crauser et al. Dijkstra shortest paths
  • Delta-Stepping shortest paths
  • Bellman-Ford Shortest Paths
  • And if as possible...Bidirectional Dijkstra

But, I'm newbie in C++... I'm reading the Boost documentation and looking examples using TIFF to better understand it but I have not got it yet. Then, how to execute this algorithms and how to hold the correct CRS of TIFF in this case?

  • It would be helpful to add a question in the body of your question. – Aaron May 16 '17 at 17:55
  • nicely answered and accepted here on SO. – Steven Kay May 16 '17 at 21:34
  • 1
    Yes @StevenKay!! I started this discussion on SO. But the image is RGB, and now my image is grayscale and I want to hold the original CRS of image and call the Boost Dijkstra functions... – Ailton Filho May 16 '17 at 23:05
  • What is "hold CRS of image"? – sehe May 17 '17 at 8:52
  • Ah sorry @sehe! The GEOTIFF image have spatial informations and CRS (Coordinate Reference System) is one of them. So, when I execute the algorithm the output TIFF image (verification.tif) loses this information. I want to keep this. – Ailton Filho May 17 '17 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.