Cleaning up the details.
You can also tour the functions in the function gallery.
These are functions that can be called individually to address problem areas in specific images, or strung together as building blocks to do more complicated operations. We’ll start with this Chrysochroa fulgidissima image, which looks alright with a first pass using
However, the angle of the iridescent green causes part of this patch to be classified as dark brown/red (color 3), resulting in a long streak and asymmetrical speckles of this color in the center of the image.
“Absorbs” all or part of a layer into the surrounding colors, optionally according to a size or location condition.
This function is really useful, but fair warning: it can be quite slow. It works by finding the color patch with which each highlighted component shares the longest border and switching the highlighted component to that color, which is more sophisticated than simply switching the patch color, but requires many more calculations. If you find yourself using this a lot, it’s a good idea to make sure you’ve downsampled your images using the
Applies one of several morphological operations from
imager to a layer (or layers) of a
recolorize object. This can be used to despeckle, fill in holes, or uniformly grow or shrink a color patch. In practice, this is mostly only useful for fixing small imperfections; anything too drastic tends to alter the overall shape of the patch.
This function is also easy to modify. Internally, it splits the color map into individual masks using
splitByColor() (another recolorize function), then converts those to pixsets for use in
imager before slotting them back in with the unchanged layers.
Sometimes, you don’t want to define fancy rules for deciding which layers to combine; you just want to combine layers. That’s what this function is for. It takes in a list of numeric vectors for layers to combine (layers in the same vector are combined; those in different list elements are kept separate).
You might notice this is a bit different than our
recluster results above. That’s because internally,
recluster actually uses
imposeColors to refit the color map, rather than just merging layers; I have found this often produces slightly nicer results, because pixels that were on the border of one cutoff or another don’t get stranded in the wrong layer. On the other hand,
mergeLayers is considerably faster.