Skip to content

Commit

Permalink
📝 add document for N-channel data
Browse files Browse the repository at this point in the history
  • Loading branch information
ToruNiina committed Apr 19, 2020
1 parent c667e0a commit b46d611
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,41 @@ int main()
Here you can access each frame, line, and pixel intuitively by using range-based
for loops.

For the N-channel data, you need one more loop.

```cpp
#include <libasd/libasd.hpp>
#include <fstream>
#include <iostream>

int main()
{
std::ifstream ifs("example.asd");
const auto data = asd::read_asd<double, asd::ch<2>>(ifs);

std::cout << "x_pixel = " << data.header.x_pixel << '\n';
std::cout << "y_pixel = " << data.header.y_pixel << '\n';

for(auto const& frames : data.channels)
{
for(auto const& frame : frames)
{
for(auto const& line : frame)
{
for(auto const& pixel : line)
{
std::cout << pixel << ','; // height [nm] for topography, ...
}
std::cout << '\n';
}
std::cout << "\n\n";
}
}
std::cout << std::flush;
return 0;
}
```

You can set file version and channel as a template parameter.

```cpp
Expand Down

0 comments on commit b46d611

Please sign in to comment.