Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Locates one or more local maxima in a grayscale image |
last modified: December 15, 2018
USAGE: maxima [-r rad ] [-n num] [-t thresh] [-u units] [-d dist] [-m metric] [-g graphic] infile [outfile]
-r ... rad ...... x,y radii for masking out peaks; integer>0; PURPOSE: To locate one or more local maxima in a grayscale image. DESCRIPTION: MAXIMA locates one or more local maxima in a grayscale image. It does this by finding the highest graylevel value and its location (via the compare function). Then it draws a black circle (ellipse) at that location and repeats the process. The process can be stopped by any combination of more than some number of maxima, the graylevel (amplitude) at a maxima is lower than some threshold value or the distance between any two maxima are less than some spacing distance. Each maxima location and its graylevel will be returned to the terminal. If the input is not grayscale it will be converted to grayscale. ARGUMENTS: -r rad ... RAD are the x,y radii for masking out peaks. Values are integers>0. One value will be used for both dimensions. The default=5. -n num ... NUM is the number of maxima used to stop the iterative process. Stopping occurs when the iteration exceeds the num value. Values are integers>0. The default=1. Note that a number must be set even if one uses thresh. -t thresh ... THRESH is the graylevel (maxima amplitude) used as the stopping threshold. Stopping occurs when a maxima graylevel is less than thresh. Values are integers>0. The default=ignore this argument. -u units ... UNITS for the graylevel threshold. Choices are: percent (or p), raw (or r), 8bit (or 8). The default=percent. -d dist ... DISTANCE in pixels between maxima used for stopping. Stopping occurs when any two maxima are too close together, i.e. less than dist. Values are integers>0. The default=ignore this argument. -m metric ... METRIC is the compare metric used to locate the maxima. Any valid IM metric may be used. The default=rmse. Only needed for Imagemagick versions less than 6.8.6-10. -g ... Indicates to display the intermediate masked images. An optional output image may be specified which will be the input image with the masked areas showing where the maxima are located. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Example 1 -- Two Proper Maxima |
||
Creation of Example |
||
Image 1 |
Image 2 |
Processing Commands |
compare -metric rmse -subimage-search |
||
Input |
Arguments: |
Maxima Locations |
156,22 gray=65535,255,100% |
Example 2 -- Two Proper Maxima -- Threshold Too Low |
||
Creation of Example |
||
Image 1 |
Image 2 |
Processing Commands |
compare -metric rmse -subimage-search |
||
Input |
Arguments: |
Maxima Locations |
156,22 gray=65535,255,100% |
Example 3 -- Six Proper Maxima -- Circular Masking |
||
Creation of Example |
||
Image 1 |
Image 2 |
Processing Commands |
compare -metric rmse -subimage-search |
||
Input |
Arguments: |
Maxima Locations |
197,10 gray=65535,255,100% |
Example 4 -- Six Proper Maxima -- Elliptical Masking |
||
Creation of Example |
||
Image 1 |
Image 2 |
Processing Commands |
compare -metric rmse -subimage-search |
||
Input |
Arguments: |
Maxima Locations |
197,10 gray=65535,255,100% |
Example 5 -- Seven Proper Maxima |
||
Creation of Example |
||
Image 1 |
Image 2 |
Processing Commands |
compare -metric rmse -subimage-search |
||
Input |
Arguments: |
Maxima Locations |
234,35 gray=65535,255,100% |
What the script does is as follows (for any channel):
|