Color Accumulators
Author: | Mitch Richling |
Updated: | 2022-03-20 18:33:01 |
Generated: | 2022-03-20 18:37:05 |
Copyright 2022 Mitch Richling. All rights reserved.
Table of Contents
1 Introduction
The Color Accumulator package contains a set of tools designed to select pixels from one or more source images to a "ColorAccumulator" image. The idea is to iteratively apply various Color Accumulator tools to pull parts of source image(s).
In operation it woks much the way ImageJ's "Create Mask
" command (Edit -> Selection -> Create Mask
) works with selections – in fact the "Color
Accumulator ROI
" script is essentially a replacement for the "Create Mask
" command. The difference being the script works in conjunction with the other
scripts in the Color Accumulator package.
My primary use case is philately – isolating overprints, postmarks, or design elements. For this application it is common to require several passes with different tools.
2 Install
Unlike most ImageJ scripts, the Color Accumulator package contains two components. The first component is the file named "About_Color_Accumulator.js
", and
it must be installed within a folder named "MJR_LIB
" inside the Fiji "plugins
" folder. This file contains the vast majority of all the code for the
Color Accumulator package, and is used by all the other scripts – which is why it must be placed in a known location. For example, on my Windows system, I
install this file as "C:\Users\richmit\PF\Fiji.app\MJR_LIB\About_Color_Accumulator.js
".
The other Javascrpt files (the ones ending in ".js
") may be installed wherever you install other scripts. I like to put them in a new menu named "MJR
", and
so I install those files in "c:\Users\richmit\PF\Fiji.app\plugins\Scripts\MJR\
".
3 Tools
3.1 Color Accumulator ColorThreshold
3.1.1 Supported Image Types
- 24-bit RGB images
3.1.2 Description
Grabs the mask property from an image, and copies all the masked pixels to a ColorAccumulator image.
What is a mask proprietary? The colorthreshold tool adds a mask proprietary to an image. The mask is indicated by the pixels painted the "Threshold Color" when the "Filtered" button in the colorthreshold dialog is pressed. Note that the mask property exists even when it is not being displayed – i.e. when one hits the "Original" button in the colorthreshold dialog. Note also that the mask property is dynamically updated as one manipulates the values in the colorthreshold dialog box so you can use this script iteratively without closing the colorthreshold dialog.
Examples:
- A used postage stamp has two postmarks of different colors. We can select each postmark using colorthreshold, and add the pixels to the accumulator.
- We have red, blue, & green bacteria on a slide. The red & blue are the same species. We can use colorthreshold to select the red ones, and add them to the accumulator. Then we can add the blue ones. Now we we have isolated both the red & blue bacteria.
3.2 Color Accumulator Empty
3.2.1 Supported Image Types
- 8-bit grayscale
- 16-bit grayscale
- 32-bit grayscale
- 24-bit RGB images
3.2.2 Description
Create a new ColorAccumulator image of the same type and size as the current slice, and filled wih a user specified color. Errors if a ColorAccumulator already exists.
ColorAccumulators have two image properties:
- "
MJR_Background_Color
" is set to a string with a decimal representation of the background color - "
MJR_ColorAccumulator
" is set to the string "T
"
3.3 Color Accumulator EqCube
3.3.1 Supported Image Types
- 8-bit grayscale
- 16-bit grayscale
- 24-bit RGB images
3.3.2 Description
Adds pixels \(P\) from a source image to a "ColorAccumulator" image if there exists a pixel \(T\) in the ROI \(R\), such that \(P_i \in [T_i-E, T_i+E]\) for all image channels \(i\) and where E is the "cube size". That is to say, we copy all pixels that have a color "close" to one of the colors in the current ROI. In this context, "close" is means all channels are within plus or minus one cube size of each other..
If cube size is zero, then this routine copies all pixels from the source image to the destination image that match one of the colors in the ROI.
If run against the ColorAccumulator image, then it will set matching pixels to the ColorAccumulator fill color. Sort of an Un-Accumulator.
Note the runtime for this tool is strongly impacted by the cube size. Values larger than 10 can have prohibitively long run times.
3.3.3 TODOs
- Add distance metric in other color spaces – HSV
- Add support for 32-bit images… Or not…
3.4 Color Accumulator Fuzzy
3.4.1 Supported Image Types
- 24-bit RGB images
3.4.2 Description
Copies pixels from a source image to an "ColorAccumulator" image that are "near" the average pixel color in the current ROI. Two colors, \(X\) & \(Y\), are near if \(\vert X_i - Y_i \vert \le W\) for all channels \(i\) and a box width of \(W\).
If run against the ColorAccumulator image, then it will set close pixels to the ColorAccumulator fill color. Sort of an Un-Accumulator.
3.4.3 TODO
- Add code for greyscale images
- Add distance metric in other color spaces – HSV
3.5 Color Accumulator ROI
3.5.1 Supported Image Types
- 8-bit grayscale
- 16-bit grayscale
- 32-bit grayscale
- 24-bit RGB images
3.5.2 Description
Adds pixels inside an ROI from a source image to an "ColorAccumulator" image.
If run against the ColorAccumulator image, then it will fill the ROI with the ColorAccumulator fill color. Sort of an Un-Accumulator.
3.6 Color Accumulator ViaMask
3.6.1 Supported Image Types
- 8-bit grayscale
- 16-bit grayscale
- 32-bit grayscale
- 24-bit RGB images
3.6.2 Description
Adds pixels from a source image to a "ColorAccumulator" image based on a third mask image.
Operates the same way when run against the ColorAccumulator image.
3.7 Mask From Color
3.7.1 Supported Image Types
- 8-bit grayscale
- 16-bit grayscale
- 32-bit grayscale
- 24-bit RGB images
3.7.2 Description
Create a new mask image the same size as the current image, with zero pixel values where the source had the given color and 255 pixel values elsewhere. Automatically prepopulates color dialog via the image "Background_Color" property making conversions of "color accumulators" easy.