Viewing asc image

Pages: 12
Hi,

I have read the data required to create a asc file image n from file and I would like to now display the image in my compiler. Is there something special I have to do to my raw file data for it to be a viewable asc picture?

Thank you.

I do not know what you mean by “asc file image”. Can you elaborate? What application(s) create such a file?
a long, long, long time ago people made images in ascii.
You can view these in any large capacity text editor, like notepad++.
turn word wrap off. Small ones are still popular for instant messaging and email footers and such.

dunno what he means by display in compiler. You can print them to the screen in a program. Your IDE has a text editor so you can see them there.

they can be quirky to get them displayed. I can't seem to manage one here, though code tag would help..
Last edited on
closed account (z05DSL3A)
Could be an a raster GIS file format developed by Esri:
https://en.wikipedia.org/wiki/Esri_grid

I think I remember seeing .asc files used used to transfer information...never used it or GIS, just remember it from when I was looking at JPEG2000 a while back.
@jonnin
Yes, I’ve written a few ASCII-image programs myself, back before GUI computing was a thing. Complete with colors and alternate text characters. I’ve even played with plan file animations and all kinds of variants.

“display in compiler” == use my compiler to compile a program that will display the image (in addition to just reading it from file)

@Grey Wolf
Could be. There are quite a few different files floating around with an .asc extension. Some of them are rather obscure.
Last edited on
Is there something special I have to do to my raw file data for it to be a viewable asc picture?

Would be easier to answer your question if you show at least the first 5 lines of your raw file.
BTW, I assume with "asc file image" you mean somthing like this -- http://img09.deviantart.net/1c57/i/2004/329/f/6/ascii_drawings_by_chibi_satan.jpg
closed account (z05DSL3A)
MikeStgt, I think your post removes any doubt I had about you.
@Grey Wolf
LOL -- it was you who supposed, terseness could be easily interpreted as argumentative, here:
http://www.cplusplus.com/forum/general/251744/2/#msg1108611

How about this one: https://dt.azadicdn.com/wp-content/uploads/2015/06/convert-image-to-ASCII-art-online-d.png
Approved? ;)
Hi, here is the first few lines of the file.

1
2
3
498 913
 704 649 716 715 807 725 728 745 702 751 825 928 1091 1005 1002 1312 1374 1119 1016 832 787 758 728 709 694 674 678 653 645 654 730 815 793 862 914 932 872 912 1117 1177 1091 987 898 1051 1000 934 839 823 801 806 882 917 932 905 948 1035 1068 1068 955 825 837 812 740 827 1095 1144 1143 1388 1535 1455 1236 1214 1303 1336 1399 1307 1131 1083 991 895 883 955 1075 1277 1462 1393 1194 1222 1023 1156 1273 1293 1396 1633 1839 1784 1528 1690 1784 1708 1610 1675 1443 1458 1297 1305 1249 1232 1004 1063 1031 1023 1007 801 750 785 788 814 897 1054 1230 1450 1078 902 1104 1400 1632 1668 1774 1620 1616 1865 1933 1690 1435 1373 1194 1365 1307 1313 1166 1124 1158 1181 1183 1255 1596 1663 1698 1730 1722 1445 1241 1123 1025 926 926 875 860 842 854 959 1032 898 832 836 846 952 999 913 941 1034 1220 1075 927 827 821 846 869 868 900 1008 1011 1026 964 950 949 949 947 940 942 951 955 1014 1158 1534 1900 2124 2150 2043 2129 2062 2000 1955 1909 1606 1280 1161 1097 1085 1074 1090 1116 1148 1224 1567 2091 2274 2352 2063 1942 2266 2134 2267 2202 2105 2224 2138 1961 1976 1873 1666 1418 1362 1522 1617 1492 1346 1402 1557 1770 2071 2026 1970 1609 1747 2035 2320 2213 2189 2304 1962 1780 2107 2327 2454 2323 2190 2107 2077 1960 1849 1726 1530 1652 1771 1625 1670 1526 1523 1474 1497 1580 1537 1599 1543 1500 1510 1411 1368 1344 1365 1379 1360 1328 1316 1336 1318 1288 1272 1257 1258 1301 1321 1326 1326 1328 1329 1333 1350 1359 1350 1338 1327 1317 1305 1294 1283 1276 1276 1278 1272 1252 1241 1235 1228 1228 1226 1224 1224 1221 1217 1216 1218 1222 1224 1222 1217 1213 1209 1204 1201 1191 1185 1177 1162 1150 1124 1109 1076 1054 1057 1073 1074 1066 1051 1050 1047 1052 1061 1084 1066 1066 1069 1090 1122 1153 1119 1080 1059 1044 1059 1047 1039 1040 1034 1032 1029 1021 1017 995 979 938 874 924 963 981 998 1022 1043 1013 1006 999 1000 1011 1017 1029 1064 1096 1105 1092 1089 1085 1067 1078 1065 1062 1017 1026 1026 1026 1030 1097 1108 1143 1173 1138 1064 981 993 1013 1018 1005 1006 1004 1024 1034 1046 1029 990 959 945 941 944 927 940 976 954 953 956 954 950 947 951 955 956 968 986 995 1028 1023 1007 962 929 873 816 883 982 1071 1072 1060 1051 1044 1032 1022 1000 925 829 849 844 816 905 955 980 1017 1042 1024 1013 1025 1023 1002 982 964 976 986 980 979 987 983 980 969 971 978 1001 1006 1003 1000 1004 1008 995 976 959 946 934 927 938 926 914 905 903 899 903 904 906 882 878 855 827 781 767 752 767 753 740 756 838 861 857 850 837 831 802 781 787 750 701 697 695 716 716 687 724 734 752 797 793 775 741 720 767 766 737 742 765 740 719 772 742 714 692 679 689 692 695 707 721 722 731 731 731 738 742 742 739 722 716 720 755 781 800 808 814 772 681 738 822 826 783 733 755 787 800 834 885 962 941 886 843 790 752 688 745 831 929 897 901 920 934 904 890 877 867 865 859 849 833 829 807 762 745 737 723 729 720 731 764 791 814 796 791 760 720 703 705 745 762 770 780 776 795 816 823 812 804 815 847 831 813 833 811 829 829 810 796 785 791 782 781 794 789 770 785 771 754 747 745 730 715 712 710 696 681 693 711 725 733 736 728 731 729 729 730 734 747 763 775 780 783 762 757 777 785 799 798 795 790 770 769 758 765 783 806 806 802 799 800 804 794 795 797 799 794 779 765 774 756 739 743 738 741 743 741 744 738 721 695 694 722 743 731 712 735 743 748 764 763 742 734 736 746 755 751 754 764 779 788 796 792 806 812 823 837 869 888 884 875 869 846 810 784 775 768 759 743 732 751 749 803 817 819 820 817 817 811 808 794 762 751 736 727 714 717 707 698 695 691 686 662 649 636 620 597 584 582 582 595 607 613 622 657 687 700 671 674 660 630 613 645 663 670 697 709 690 702 702 695 704 701 713 727 706 714 728 733 710 702 704 689 684 682 673 661 658 659 651 671 675 704 728 720 628 647 650 613 617 613 622 665 661 620 614 634 674 698 735 749 710 675 676 680 701 715 662 589 648 710 647 697 697 638 644 677 708 691 617 586 581 578 583 588 578 601 623 644 672 711 706 694 685 689 670 653 632 624 601 591 589 595 608 586 572 566 563 560 566 558 563 566 558 558 558 557 557 557 557 557 557 557 557 560 572 568 585
 883 736 775 812 851 803 843 872 862 930 1108 1274 1316 1188 1108 1251 1289 1145 964 846 830 771 742 834 925 930 829 663 649 746 815 845 881 988 1155 1194 1070 9


So, I think it's something like a ppm file where it specifies rows and columns then grouping of red green and blue.
Last edited on
ok. so do you want to see the image, or display it in code?
that looks like ye olde ".raw" file format to me -- rows, cols, rgb array. I don't really know how you are trying to display it here, but that is my current best guess. There are programs that can display .raw files so that isnt too hard to do. Displaying it yourself is a bit harder: you need at least the ability to doodle on the screen, even if its just the windows draw buffer or something simple like that.

Could not find yet a spec about .raw similar this about TIFF:
https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
Such a paper would be helpful.
raw does not have a spec; its a convention if its anything at all. The closest thing is indeed a tiff or uncompressed tga type file. You also see them with a .rgb extension.
wiki has an extensive ramble about it. https://en.wikipedia.org/wiki/Raw_image_format

and FWIW AVI uncompressed video is a series of raws (yea, its huge).
Last edited on
Thank you for the link. Now we know about the .raw format. What about .asc?

The three example lines you show, first is #row and #columns or vv? Second line are 913 blank delimited words, next only 38 (I assume a truncated record).

The closest thing is indeed a tiff
For sure it is not. TIFF stands for Tagged Image File Format and besides few implicit values all data is tagged. This allows to have several very different graphic formats encapsulated within a .tif file. What you present as example looks much simpler, no Image File Header, no hint about byte order, etc.

Why do you want to convert it? Just to display it as a picture? In that case you could use a viewer like https://www.irfanview.com/ Irfan claims to read .raw with it.
closed account (z05DSL3A)
jonnin wrote:
raw does not have a spec; its a convention if its anything at all.
Are you talking about 'raw' files from digital cameras and such i.e. the data dumped off of the image sensor with no processing? There are plenty of specs for them...not necessarily freely available.
Or are you talking just an ad hoc ASCII dump of image data?

I think the OP could give more detail about where the file originates or what spec was used to write the code they use to read the data. Also info about what platform they are using would be good.
Or are you talking just an ad hoc ASCII dump of image data
this, mostly. Some sensors provide exactly that, though actual (advanced) cameras tend to garble or compress or mess with it. There is a whole world of RGB, RGBX, BGR, greyscale, and similar straight byte dump image files. Again, we are just guessing... so far we have a small number of integers. Open the thing in a raw image viewer. If that works, we can proceed easily. If it does not, need to drop back and punt on the format, and find out what it really is. Or, check to see if widthxheight+ 8 or so bytes == the file size. If so, its likely a raw...

Hi,

Okay, sorry I didn't get back with more information sooner.

The asc file had to be opened, read in, and stored in a class dynamic array. Then, it's scaled to fit the 0-255 pixel range of a ppm and then converted/saved to a ppm file.

It was a grayscale image of course due to having to set each r g b to the same value.

Now, I just have to figure out how to do a recursive call on a function to autofill part of the image with a certain color.
Well, good luck with that, since both your posts so far have shared absolutely no usable information about your project. Might as well tell use you need to flobbotz the bogometer using the XYZ method, and you are having trouble with the recursive part.
That's my bad. When I made the post, I would've had to post pretty much my entire main, class.cpp, and header file since I was completely lost, and that seemed like a douchey thing to do. And, believe it or not, reading what you all said actually made things click for me. So technically, you all gave me exactly what I needed, and I didn't have to risk point deduction for too much outside help on homework.

I'll mark it resolved, and then on Monday(the assignment due date), I'll post relevant code in case someone else ever has the same project or something similar.

Thank you all.
Now, I just have to figure out how to do a recursive call on a function to autofill part of the image with a certain color.
If it's not for the joy to reinvent the wheel once more and on your own, I would suggest to delegate this task where it is solved since long (IrfanView for example). Currently I can not see any reason for a recursive call to recolour a Portable Pixelmap formated pic.
BTW, I assume you know this: http://netpbm.sourceforge.net/doc/libnetpbm.html
MikeStgt,

Thank you. I didn't know about that library at all actually.

And as far as not needing recursion, I was operating under the belief that the only way to auto-fill and boundary was with recursion. This is all news to me.
Pages: 12