简体   繁体   English

将 1mb 数据编码为可解码模拟图像的最佳方法是什么?

[英]What is the best way to encode 1mb of data into a decodable analog image?

  1. The image generated will have to be space restricted, not too big.生成的图像必须受空间限制,不能太大。
  2. By analog i mean, it should be printed out.通过模拟我的意思是,它应该被打印出来。 Much like how a QR code works, except, storing much larger size!很像 QR 码的工作方式,除了存储更大的尺寸!
  3. B/w image黑白图像
  4. Can be compressed (obviously because its better, time taken to uncompress should not be much either, so compression can be minimal)可以压缩(显然因为它更好,解压缩所花费的时间也不应该太多,所以压缩可以是最小的)
  5. You can assume any lower print density, and bits per pixel would be directly related to the solution you propose.您可以假设任何较低的打印密度,每像素位数将与您提出的解决方案直接相关。 Please go ahead and assume:)请提前拨打 go 并承担:)

I'm not sure how you could exactly encode this to fit on paper... I think the best way is to convert your digital information into a more compact analog representation.我不确定如何将其准确编码以适合纸张……我认为最好的方法是将数字信息转换为更紧凑的模拟表示形式。 To clarify... What has been proposed is to take the digital information and represent it (with bits) digitally on an analog medium.澄清... 已经提出的是获取数字信息并在模拟媒体上以数字方式(用位)表示它。 What I'm trying to say is take the digital info, convert it and represent it in an analog form on an analog medium.我想说的是获取数字信息,将其转换并在模拟媒体上以模拟形式表示。 How to do this?这该怎么做? I have no idea, but I have a lead for you.我不知道,但我有线索给你。

Remember the Voyager Golden Records?还记得航海者金唱片吗? They fit 116 (115?) images onto the disks, both simple B&W images and full size, color images with high(ish) resolution.他们将 116(115?)张图像放入磁盘,既有简单的黑白图像,也有高分辨率的全尺寸彩色图像。 They did it with an analog box of wavelengths representing digital bits over 512 (2^9) lines.他们用一个代表 512 (2^9) 行数字比特的波长模拟盒来做到这一点。

Not sure if that helps, but maybe it gives you (or someone else) an idea?不确定这是否有帮助,但也许它给了你(或其他人)一个想法?

Assuming no overhead for error correction, and 1mm resolution, you're looking at a 1 x 1 meter image.假设没有用于纠错的开销和 1 毫米的分辨率,您正在查看 1 x 1 米的图像。 This assumes no compression (how compressible your data is really depends) and no real encoding scheme.这假设没有压缩(您的数据的可压缩性实际上取决于)并且没有真正的编码方案。 This is not practical.这是不切实际的。

I'd break up your data into ~5kb chunks, encode them as QR codes together with their sequence numbers, and use the collection of QR codes.我会将您的数据分解为 ~5kb 块,将它们连同序列号一起编码为 QR 码,并使用 QR 码集合。 Each image has built-in error correction.每个图像都有内置的纠错功能。 You'll end up with maybe two hundred 15*15cm images.您最终可能会得到两百张 15*15cm 的图像。 At least you'll be able to use regular paper and printers for it.至少你可以使用普通的纸张和打印机。

The reason I suggest QR codes is that they have error correction built in, so you have more tolerance for smeared ink, wrinkled or torn paper, or a less than perfect camera/scanner.我建议使用 QR 码的原因是它们内置了纠错功能,因此您对污迹墨水、起皱或破损的纸张或不太完美的相机/扫描仪有更大的容忍度。 Plus, the overhead of the error correction isn't bad, and you're getting something like 90% use out of your paper.此外,纠错的开销还不错,而且您的论文使用率大约为 90%。 Assuming some maximum resolution that you're willing to use for a pixel, regardless of encoding scheme.假设无论编码方案如何,您都愿意为像素使用某个最大分辨率。 Plus, they're fast to decode, hence their name.此外,它们的解码速度很快,因此得名。

How about encoding your 1 MB into an image and print is at high enough resolution and color depth , this is a simple straight forward approach.如何将 1 MB 编码成图像并以足够高的分辨率颜色深度打印,这是一种简单直接的方法。

Recovering of the data depends greatly on the capabilities of your scanner/camera or "analog" reader (optical resolution etc.)数据的恢复在很大程度上取决于您的扫描仪/相机或“模拟”阅读器(光学分辨率等)的能力

No error correction in this example, redundancy can be included in the data itself.本例中没有纠错,数据本身可以包含冗余。

此处为 1 MB 图片

Which is a container that store this image of 1.1 MB:这是一个存储此 1.1 MB 图像的容器:

此处图片 1.1 MB 数据

Images hosted on图片托管于ipfs

Other approaches: store data on paper .其他方法:将数据存储在纸上

The Perl script to create the image is below (it makes use of convert from imageMagick):创建图像的 Perl 脚本如下(它使用convert from imageMagick):

#!/usr/bin/perl

# this script take any data and make an image with it (format .png)

# deps
#  convert from ImageMagick
our $dbug=0;
#--------------------------------
# -- Options parsing ...
#
my $if = undef;
my $of = undef;
while (@ARGV && $ARGV[0] =~ m/^-/)
{
  $_ = shift;
  #/^-(l|r|i|s)(\d+)/ && (eval "\$$1 = \$2", next);
  if (/^-v(?:erbose)?/) { $verbose= 1; }
  elsif (/^-?if?=?([\w.]+)?/) { $if= $1?$1:shift; }
  elsif (/^-?of?=?([\w.]+)?/) { $of= $1?$1:shift; }
  else                  { die "Unrecognized switch: $_\n"; }

}
#understand variable=value on the command line...
eval "\$$1='$2'"while $ARGV[0] =~ /^(\w+)=(.*)/ && shift;

my $data;
if (! defined $of) {
 if (@ARGV) { $of = pop @ARGV }
 else { $of = '-' }
}
if (defined $if) {
   local *IN; 
   local $/ = undef;
   open IN,'<',$if;
   $data = <IN>;
   close IN;
} else {
   if ($ARGV > 0) { $if = '<>'; }
     elsif ($#ARGV == 0) { $if = $ARGV[0]; }
     else { $if = '-'; }
   local $/ = undef;
   $data = <>;
   close STDIN;

}
my $size = length($data);

my $pi = atan2(0,-1);
#my $iratio = 4/3; # y/x
my $iratio = $pi; # x/y

my $xy = $size/3 * ($iratio);
my $x = sqrt($xy);
if ($verbose) {
   printf STDERR "if: %s\n",$if;
   printf STDERR "of: %s\n",$of;
   printf STDERR "size: %s\n",$size;
   printf STDERR "x: %.3f\n",$x;
   printf STDERR "y: %.3f\n",$x / $iratio;
}
my $y = int($x / $iratio + $iratio);
   $x = int( ( $size / 3 + $y - 1) / $y ); 
my $n = $x*$y*3;
my $delta = $n - $size;
if ($delta < 0) {
   $x++; 
   $n = $x*$y*3;
   $delta = $n - $size;
}
my $pad = "\x00" x $delta;
if ($verbose) {
   printf STDERR "playload: %sx%s = %s\n",$x,$y,$n;
   printf STDERR "delta: %s\n", $delta;
}

my $hdr = <<"EOS";
P6
$x $y
255
EOS

#my $fname = $file; $fname =~ s,.*/,,;
#my $bname = $fname; $bname =~ s/\.[^\.]*$//;
#printf STDERR "fname: %s\n",$fname;
#printf STDERR "fname: %s.png\n",$bname;

local *PPM; open PPM,"| convert -compress LZW -strip -quality 90 ppm:- png:$of";
print PPM $hdr;
binmode(PPM);
print PPM $data;
print PPM $pad;
close PPM;

exit $?;

1; # $Source: /my/perl/scripts/dat2png.pl$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM