Quickly visualize a large binary matrix?

I am looking for a simple and especially fast opportunity to convert a binary matrix (consisting of only 0 and 1), stored in a text file, into some kind of plot. The black and white bitmap will complete my visualization task. I tried with gnuplot, but I think the first time gnuplot is missing, because I have a lot of data (at least dozens of MiB), and the memory consumption and processing time are terrible.

When searching for solutions, I mainly found material related to stored binary matrices (data format) and the ability to read a binary data format, for example. Gnuplot.

Do you know about any programs that can convert a text matrix to a bitmap quickly ? I’m even thinking about writing a small C program that does this, but since I can’t appreciate how difficult it is to create bitmap images in a way that I never did image processing before it would be nice to use existing tools, if possible.

Thanks!

+4
source share
2 answers

Use netpbm. For instance:.

$ cat | pnmtopng > circle.png P1 10 10 0001111000 0111111110 0111111110 1111111111 1111111111 1111111111 1111111111 0111111110 0111111110 0001111000 $ file circle.png circle.png: PNG image, 10 x 10, 1-bit grayscale, non-interlaced 

Here is the end result: enter image description here

+7
source

The only C image I've worked with is the C JPG library, which may or may not suit your needs. This is not the fastest thing in the world, but it is easy to work with, and there are several shortcuts that you can do in the logic itself to make it a little faster.

What I think of is literally repeating through your matrix and outputting a black or white pixel based on your matrix value; I'm just pretty sure whether it will be faster or more efficient than gnuplot.

0
source

Source: https://habr.com/ru/post/1338059/


All Articles