更新答案 - 2021 年 4 月
以下是关于随机图像的更多想法:
随机彩色方块
magick -size 8x8 xc: +noise Random -scale 100x100 RandomColouredSquares.png
随机黑白填字游戏
magick -size 8x8 xc:gray +noise Random -threshold 50% -scale 100x100 RandomCrosswords.png
随机灰色模糊
magick -size 8x8 xc:gray +noise Random -resize 100x100 RandomGreyBlur.png
随机彩色模糊
magick -size 5x5 xc: +noise Random -auto-level -resize 100x100 RandomColouredBlur.png
盐和胡椒粉随意
magick -size 100x100 xc:gray +noise Random -threshold 1% -negate RandomSaltAndPepper.png
重复的彩色图案
magick -size 50x50 xc: +noise random -virtual-pixel tile -blur 0x6 -auto-level -write MPR:tile +delete -size 250x250 tile:MPR:tile RandomRepeatedPattern.png
更新答案 - 2021 年 3 月
如果您想要随机噪声类型的图像,请参阅下面的原始答案,请注意您应该替换convert
with magick
在这些例子中,如果与图像魔术师v7 以后。
如果你想要纯随机颜色的图像,你可以这样做:
magick -size 400x200 xc:"rgb($((RANDOM%255)),$((RANDOM%255)),$((RANDOM%255)))" image.png
样本输出
如果您想要随机大小和随机纯色的图像,您可以将其用于 200..264 像素宽 x 100..132 像素高之间的图像:
magick -size "$(((RANDOM%64)+200))x$(((RANDOM%32)+100))" xc:"rgb($((RANDOM%255)),$((RANDOM%255)),$((RANDOM%255)))"random.png
样本输出
原答案
您可以使用ImageMagick
(默认安装在大多数 Linux 发行版上)生成随机噪声图像,如下所示:
convert -size 300x200 xc:gray +noise random out.bmp
where 300
是宽度和200
是高度(仅是示例)。
其他类型的噪音都可以,运行即可
convert -list noise
Output
Gaussian
Impulse
Laplacian
Multiplicative
Poisson
Random
Uniform
如果噪音对你来说太吵了;-),你可以用以下方法减弱它
convert -size 300x200 xc:gray -attenuate 0.5 +noise random out.bmp
衰减 50%
以下是不同类型的一些示例:
以下是相应的分布直方图:
为了完整起见,请注意这个答案出现在 Daniel Barrett 的书中“命令行中的高效 Linux”.