#image #difference #generate #command-line-tool #blue-red #subtracting

bin+lib brdiff

A command-line tool for subtracting images to generate a new blue-red difference image

2 unstable releases

0.2.0 Dec 6, 2020
0.1.0 Apr 20, 2020

#998 in Images

MIT license

7KB
99 lines

brdiff

Subtract two images to create a new blue-red difference image.

Pixels will appear blue in places where the first image's luminance was greater than the second, and will appear red when the opposite holds true. If the subtracted pixels are close or equal in value, the resulting pixel will approach black.

Such an image subtraction function may be useful when performing multispectral image subtraction to help emphasize areas of an object containing a specific material. Unlike a normal differencing function (resulting in a greyscale output), a blue-red difference will distinguish positive signals (blue) from the inverse (red).

Installing

First ensure that Rust is installed by following these instructions.

Then, run the following command:

cargo install brdiff

Without Cargo/Rust:

You may also grab the latest release from here run it manually.

(With this method, you will need to call the command via ./brdiff instead of brdiff, unless you also add its location to your $PATH.)

Usage

To generate a blue-red difference image from two input images, enter this command, substituting the three arguments with file names:

$ ./brdiff --help
usage:
  brdiff [--help] [--invert] <base_image> <subtraction_image> <difference_image>

Supported input and output formats include BMP, PPM, JPG/JPEG, and TIF/TIFF.

Here is an example command using .tif files:

./brdiff image_735nm.tif image_660nm.tif image_br.tif

To output an image with a white background (instead of black), use the --invert argument:

./brdiff --invert image_735nm.jpg image_660nm.jpg image_br_whitebg.jpg

The output image will be overwritten if it already exists, so be careful, and keep backups.

Contributing

  • Check the issue tracker and consider creating a new issue.
  • Fork the project and create a new branch for your contribution.
  • Write, commit, and push your contribution to your branch.
  • Make sure the project builds (make) and functionality still works as expected.
  • Submit a pull request.

Dependencies

~5MB
~60K SLoC