#!/usr/bin/perl

use PDL;
use PDL::IO::FastRaw;

# Read the data into the $brain piddle
$brain = readfraw("brain", { Dims => [351,412], ReadOnly => 1 });

# Create a second piddle (351 high and 412 wide) full of zeroes
$bullseye = zeroes(412, 351);

# Replace each element of $bullseye with its distance from the center.
rvals(inplace($bullseye));

# Clip $bullseye to 255.
$bullseye = 255 * ($bullseye >= 255) + $bullseye * ($bullseye < 255);

# Create a new piddle, $ghost, that is a weighted sum of $brain and $bullseye.
$ghost = $brain/2 + $bullseye/1.5;

# Coerce each element of $ghost to a single byte.
$ghost = byte $ghost;

# Write it out to a file named "vignette".
writefraw($ghost, "vignette");
