2015-03-19 116 views
0

任何人都可以提出一种方法,我可以用它从图像中提取像素。不是作为文字,而是作为图像本身。我想从图像中获取所有单独的像素作为新图像。每个图像一个像素。我能找到的唯一解决方案就是打印像素的方法,也许我在搜索时没有使用正确的关键字,但希望这里有人能指出我正确的方向。从图像中提取像素,作为新的小图像

有问题的图片是jpg,并且其中有大约900张我希望变成分色像素图片。

谢谢!

Arantxa

+0

您正在使用什么操作系统? – 2015-03-19 11:29:38

回答

0

我无法想象,你为什么会想这样做,但如果你使用的ImageMagick,这是安装在大多数Linux发行版,可供OSX(最好通过homebrew)和Windows,你可以做这样的:

convert in.jpg -crop 1x1 p%d.jpg 

,你会得到p0.jpgp1.jpg等。

我们可以测试这样的...

# Create a 4x1 black-white gradient 
convert -size 4x1 gradient:black-white in.jpg 

# Chop it into 1x1 pixel image lumps 
convert in.jpg -crop 1x1 p%d.jpg 

# Check what we got - yes, 4 images each 1x1 
identify p* 
p0.jpg JPEG 1x1 1x1+0+0 8-bit Gray 256c 160B 0.000u 0:00.000 
p1.jpg[1] JPEG 1x1 1x1+0+0 8-bit Gray 256c 160B 0.000u 0:00.000 
p2.jpg[2] JPEG 1x1 1x1+0+0 8-bit Gray 256c 160B 0.000u 0:00.000 
p3.jpg[3] JPEG 1x1 1x1+0+0 8-bit Gray 256c 160B 0.000u 0:00.000 

# Scale the little lumps up and append them side-by-side to see result - add border so white square is visible 
convert p*.jpg -scale 100 +append -bordercolor red -border 5x5 out.png 

enter image description here