net.algart.matrices.morphology.RankPrecision Maven / Gradle / Ivy
Show all versions of algart Show documentation
/*
* The MIT License (MIT)
*
* Copyright (c) 2007-2024 Daniel Alievsky, AlgART Laboratory (http://algart.net)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.algart.matrices.morphology;
/**
* Some predefined precision characteristics of rank operations, described in {@link RankMorphology}
* interface.
*
* Note: for every {@link #bitLevels() bit levels} array, represented by this enum,
* there are both instances of this class with {@link #interpolated()}==false
* and with {@link #interpolated()}==true
.
*
* This class is immutable and thread-safe:
* there are no ways to modify settings of the created instance.
*
* @author Daniel Alievsky
*/
public enum RankPrecision implements CustomRankPrecision {
/*Repeat() \{1\} ==> {2},,{3},,{4},,{5},,{6},,{7},,{8},,{4, 8},,{9},,{10},,{5, 10},,
{11},,{5, 11},,{12},,{6, 12},,{4, 8, 12},,{13},,{6, 13},,{14},,{7, 14},,
{15},,{7, 15},,{5, 10, 15},,{16},,{8, 16},,{5, 10, 16},,
{20},,{10, 20},,{6, 13, 20},,{5, 10, 15, 20},,
{22},,{11, 22},,{7, 14, 22},,{5, 10, 15, 22},,
{24},,{12, 24},,{8, 16, 24},,{6, 12, 18, 24},,{4, 8, 12, 16, 20, 24},,
{26},,{13, 26},,{8, 16, 26},,{6, 12, 18, 26};;
(?<=BITS_)1 ==> 2,,3,,4,,5,,6,,7,,8,,8_PER_4,,9,,10,,10_PER_5,,
11,,11_PER_5,,12,,12_PER_6,,12_PER_4,,13,,13_PER_6,,14,,14_PER_7,,
15,,15_PER_7,,15_PER_5,,16,,16_PER_8,,16_PER_5,,
20,,20_PER_10,,20_PER_7,,20_PER_5,,
22,,22_PER_11,,22_PER_7,,22_PER_5,,
24,,24_PER_12,,24_PER_8,,24_PER_6,,24_PER_4,,
26,,26_PER_13,,26_PER_8,,26_PER_6;;
(BITS_26_PER_6_\w+\(.*?\))\, ==> $1;,,... */
/**
* Here {@link #bitLevels()}={1}
, {@link #interpolated()}=false
.
*/
BITS_1(new int[]{1}, false),
/**
* Here {@link #bitLevels()}={1}
, {@link #interpolated()}=true
.
*/
BITS_1_INTERPOLATED(new int[]{1}, true),
/*Repeat.AutoGeneratedStart !! Auto-generated: NOT EDIT !! */
/**
* Here {@link #bitLevels()}={2}
, {@link #interpolated()}=false
.
*/
BITS_2(new int[]{2}, false),
/**
* Here {@link #bitLevels()}={2}
, {@link #interpolated()}=true
.
*/
BITS_2_INTERPOLATED(new int[]{2}, true),
/**
* Here {@link #bitLevels()}={3}
, {@link #interpolated()}=false
.
*/
BITS_3(new int[]{3}, false),
/**
* Here {@link #bitLevels()}={3}
, {@link #interpolated()}=true
.
*/
BITS_3_INTERPOLATED(new int[]{3}, true),
/**
* Here {@link #bitLevels()}={4}
, {@link #interpolated()}=false
.
*/
BITS_4(new int[]{4}, false),
/**
* Here {@link #bitLevels()}={4}
, {@link #interpolated()}=true
.
*/
BITS_4_INTERPOLATED(new int[]{4}, true),
/**
* Here {@link #bitLevels()}={5}
, {@link #interpolated()}=false
.
*/
BITS_5(new int[]{5}, false),
/**
* Here {@link #bitLevels()}={5}
, {@link #interpolated()}=true
.
*/
BITS_5_INTERPOLATED(new int[]{5}, true),
/**
* Here {@link #bitLevels()}={6}
, {@link #interpolated()}=false
.
*/
BITS_6(new int[]{6}, false),
/**
* Here {@link #bitLevels()}={6}
, {@link #interpolated()}=true
.
*/
BITS_6_INTERPOLATED(new int[]{6}, true),
/**
* Here {@link #bitLevels()}={7}
, {@link #interpolated()}=false
.
*/
BITS_7(new int[]{7}, false),
/**
* Here {@link #bitLevels()}={7}
, {@link #interpolated()}=true
.
*/
BITS_7_INTERPOLATED(new int[]{7}, true),
/**
* Here {@link #bitLevels()}={8}
, {@link #interpolated()}=false
.
*/
BITS_8(new int[]{8}, false),
/**
* Here {@link #bitLevels()}={8}
, {@link #interpolated()}=true
.
*/
BITS_8_INTERPOLATED(new int[]{8}, true),
/**
* Here {@link #bitLevels()}={4, 8}
, {@link #interpolated()}=false
.
*/
BITS_8_PER_4(new int[]{4, 8}, false),
/**
* Here {@link #bitLevels()}={4, 8}
, {@link #interpolated()}=true
.
*/
BITS_8_PER_4_INTERPOLATED(new int[]{4, 8}, true),
/**
* Here {@link #bitLevels()}={9}
, {@link #interpolated()}=false
.
*/
BITS_9(new int[]{9}, false),
/**
* Here {@link #bitLevels()}={9}
, {@link #interpolated()}=true
.
*/
BITS_9_INTERPOLATED(new int[]{9}, true),
/**
* Here {@link #bitLevels()}={10}
, {@link #interpolated()}=false
.
*/
BITS_10(new int[]{10}, false),
/**
* Here {@link #bitLevels()}={10}
, {@link #interpolated()}=true
.
*/
BITS_10_INTERPOLATED(new int[]{10}, true),
/**
* Here {@link #bitLevels()}={5, 10}
, {@link #interpolated()}=false
.
*/
BITS_10_PER_5(new int[]{5, 10}, false),
/**
* Here {@link #bitLevels()}={5, 10}
, {@link #interpolated()}=true
.
*/
BITS_10_PER_5_INTERPOLATED(new int[]{5, 10}, true),
/**
* Here {@link #bitLevels()}={11}
, {@link #interpolated()}=false
.
*/
BITS_11(new int[]{11}, false),
/**
* Here {@link #bitLevels()}={11}
, {@link #interpolated()}=true
.
*/
BITS_11_INTERPOLATED(new int[]{11}, true),
/**
* Here {@link #bitLevels()}={5, 11}
, {@link #interpolated()}=false
.
*/
BITS_11_PER_5(new int[]{5, 11}, false),
/**
* Here {@link #bitLevels()}={5, 11}
, {@link #interpolated()}=true
.
*/
BITS_11_PER_5_INTERPOLATED(new int[]{5, 11}, true),
/**
* Here {@link #bitLevels()}={12}
, {@link #interpolated()}=false
.
*/
BITS_12(new int[]{12}, false),
/**
* Here {@link #bitLevels()}={12}
, {@link #interpolated()}=true
.
*/
BITS_12_INTERPOLATED(new int[]{12}, true),
/**
* Here {@link #bitLevels()}={6, 12}
, {@link #interpolated()}=false
.
*/
BITS_12_PER_6(new int[]{6, 12}, false),
/**
* Here {@link #bitLevels()}={6, 12}
, {@link #interpolated()}=true
.
*/
BITS_12_PER_6_INTERPOLATED(new int[]{6, 12}, true),
/**
* Here {@link #bitLevels()}={4, 8, 12}
, {@link #interpolated()}=false
.
*/
BITS_12_PER_4(new int[]{4, 8, 12}, false),
/**
* Here {@link #bitLevels()}={4, 8, 12}
, {@link #interpolated()}=true
.
*/
BITS_12_PER_4_INTERPOLATED(new int[]{4, 8, 12}, true),
/**
* Here {@link #bitLevels()}={13}
, {@link #interpolated()}=false
.
*/
BITS_13(new int[]{13}, false),
/**
* Here {@link #bitLevels()}={13}
, {@link #interpolated()}=true
.
*/
BITS_13_INTERPOLATED(new int[]{13}, true),
/**
* Here {@link #bitLevels()}={6, 13}
, {@link #interpolated()}=false
.
*/
BITS_13_PER_6(new int[]{6, 13}, false),
/**
* Here {@link #bitLevels()}={6, 13}
, {@link #interpolated()}=true
.
*/
BITS_13_PER_6_INTERPOLATED(new int[]{6, 13}, true),
/**
* Here {@link #bitLevels()}={14}
, {@link #interpolated()}=false
.
*/
BITS_14(new int[]{14}, false),
/**
* Here {@link #bitLevels()}={14}
, {@link #interpolated()}=true
.
*/
BITS_14_INTERPOLATED(new int[]{14}, true),
/**
* Here {@link #bitLevels()}={7, 14}
, {@link #interpolated()}=false
.
*/
BITS_14_PER_7(new int[]{7, 14}, false),
/**
* Here {@link #bitLevels()}={7, 14}
, {@link #interpolated()}=true
.
*/
BITS_14_PER_7_INTERPOLATED(new int[]{7, 14}, true),
/**
* Here {@link #bitLevels()}={15}
, {@link #interpolated()}=false
.
*/
BITS_15(new int[]{15}, false),
/**
* Here {@link #bitLevels()}={15}
, {@link #interpolated()}=true
.
*/
BITS_15_INTERPOLATED(new int[]{15}, true),
/**
* Here {@link #bitLevels()}={7, 15}
, {@link #interpolated()}=false
.
*/
BITS_15_PER_7(new int[]{7, 15}, false),
/**
* Here {@link #bitLevels()}={7, 15}
, {@link #interpolated()}=true
.
*/
BITS_15_PER_7_INTERPOLATED(new int[]{7, 15}, true),
/**
* Here {@link #bitLevels()}={5, 10, 15}
, {@link #interpolated()}=false
.
*/
BITS_15_PER_5(new int[]{5, 10, 15}, false),
/**
* Here {@link #bitLevels()}={5, 10, 15}
, {@link #interpolated()}=true
.
*/
BITS_15_PER_5_INTERPOLATED(new int[]{5, 10, 15}, true),
/**
* Here {@link #bitLevels()}={16}
, {@link #interpolated()}=false
.
*/
BITS_16(new int[]{16}, false),
/**
* Here {@link #bitLevels()}={16}
, {@link #interpolated()}=true
.
*/
BITS_16_INTERPOLATED(new int[]{16}, true),
/**
* Here {@link #bitLevels()}={8, 16}
, {@link #interpolated()}=false
.
*/
BITS_16_PER_8(new int[]{8, 16}, false),
/**
* Here {@link #bitLevels()}={8, 16}
, {@link #interpolated()}=true
.
*/
BITS_16_PER_8_INTERPOLATED(new int[]{8, 16}, true),
/**
* Here {@link #bitLevels()}={5, 10, 16}
, {@link #interpolated()}=false
.
*/
BITS_16_PER_5(new int[]{5, 10, 16}, false),
/**
* Here {@link #bitLevels()}={5, 10, 16}
, {@link #interpolated()}=true
.
*/
BITS_16_PER_5_INTERPOLATED(new int[]{5, 10, 16}, true),
/**
* Here {@link #bitLevels()}={20}
, {@link #interpolated()}=false
.
*/
BITS_20(new int[]{20}, false),
/**
* Here {@link #bitLevels()}={20}
, {@link #interpolated()}=true
.
*/
BITS_20_INTERPOLATED(new int[]{20}, true),
/**
* Here {@link #bitLevels()}={10, 20}
, {@link #interpolated()}=false
.
*/
BITS_20_PER_10(new int[]{10, 20}, false),
/**
* Here {@link #bitLevels()}={10, 20}
, {@link #interpolated()}=true
.
*/
BITS_20_PER_10_INTERPOLATED(new int[]{10, 20}, true),
/**
* Here {@link #bitLevels()}={6, 13, 20}
, {@link #interpolated()}=false
.
*/
BITS_20_PER_7(new int[]{6, 13, 20}, false),
/**
* Here {@link #bitLevels()}={6, 13, 20}
, {@link #interpolated()}=true
.
*/
BITS_20_PER_7_INTERPOLATED(new int[]{6, 13, 20}, true),
/**
* Here {@link #bitLevels()}={5, 10, 15, 20}
, {@link #interpolated()}=false
.
*/
BITS_20_PER_5(new int[]{5, 10, 15, 20}, false),
/**
* Here {@link #bitLevels()}={5, 10, 15, 20}
, {@link #interpolated()}=true
.
*/
BITS_20_PER_5_INTERPOLATED(new int[]{5, 10, 15, 20}, true),
/**
* Here {@link #bitLevels()}={22}
, {@link #interpolated()}=false
.
*/
BITS_22(new int[]{22}, false),
/**
* Here {@link #bitLevels()}={22}
, {@link #interpolated()}=true
.
*/
BITS_22_INTERPOLATED(new int[]{22}, true),
/**
* Here {@link #bitLevels()}={11, 22}
, {@link #interpolated()}=false
.
*/
BITS_22_PER_11(new int[]{11, 22}, false),
/**
* Here {@link #bitLevels()}={11, 22}
, {@link #interpolated()}=true
.
*/
BITS_22_PER_11_INTERPOLATED(new int[]{11, 22}, true),
/**
* Here {@link #bitLevels()}={7, 14, 22}
, {@link #interpolated()}=false
.
*/
BITS_22_PER_7(new int[]{7, 14, 22}, false),
/**
* Here {@link #bitLevels()}={7, 14, 22}
, {@link #interpolated()}=true
.
*/
BITS_22_PER_7_INTERPOLATED(new int[]{7, 14, 22}, true),
/**
* Here {@link #bitLevels()}={5, 10, 15, 22}
, {@link #interpolated()}=false
.
*/
BITS_22_PER_5(new int[]{5, 10, 15, 22}, false),
/**
* Here {@link #bitLevels()}={5, 10, 15, 22}
, {@link #interpolated()}=true
.
*/
BITS_22_PER_5_INTERPOLATED(new int[]{5, 10, 15, 22}, true),
/**
* Here {@link #bitLevels()}={24}
, {@link #interpolated()}=false
.
*/
BITS_24(new int[]{24}, false),
/**
* Here {@link #bitLevels()}={24}
, {@link #interpolated()}=true
.
*/
BITS_24_INTERPOLATED(new int[]{24}, true),
/**
* Here {@link #bitLevels()}={12, 24}
, {@link #interpolated()}=false
.
*/
BITS_24_PER_12(new int[]{12, 24}, false),
/**
* Here {@link #bitLevels()}={12, 24}
, {@link #interpolated()}=true
.
*/
BITS_24_PER_12_INTERPOLATED(new int[]{12, 24}, true),
/**
* Here {@link #bitLevels()}={8, 16, 24}
, {@link #interpolated()}=false
.
*/
BITS_24_PER_8(new int[]{8, 16, 24}, false),
/**
* Here {@link #bitLevels()}={8, 16, 24}
, {@link #interpolated()}=true
.
*/
BITS_24_PER_8_INTERPOLATED(new int[]{8, 16, 24}, true),
/**
* Here {@link #bitLevels()}={6, 12, 18, 24}
, {@link #interpolated()}=false
.
*/
BITS_24_PER_6(new int[]{6, 12, 18, 24}, false),
/**
* Here {@link #bitLevels()}={6, 12, 18, 24}
, {@link #interpolated()}=true
.
*/
BITS_24_PER_6_INTERPOLATED(new int[]{6, 12, 18, 24}, true),
/**
* Here {@link #bitLevels()}={4, 8, 12, 16, 20, 24}
, {@link #interpolated()}=false
.
*/
BITS_24_PER_4(new int[]{4, 8, 12, 16, 20, 24}, false),
/**
* Here {@link #bitLevels()}={4, 8, 12, 16, 20, 24}
, {@link #interpolated()}=true
.
*/
BITS_24_PER_4_INTERPOLATED(new int[]{4, 8, 12, 16, 20, 24}, true),
/**
* Here {@link #bitLevels()}={26}
, {@link #interpolated()}=false
.
*/
BITS_26(new int[]{26}, false),
/**
* Here {@link #bitLevels()}={26}
, {@link #interpolated()}=true
.
*/
BITS_26_INTERPOLATED(new int[]{26}, true),
/**
* Here {@link #bitLevels()}={13, 26}
, {@link #interpolated()}=false
.
*/
BITS_26_PER_13(new int[]{13, 26}, false),
/**
* Here {@link #bitLevels()}={13, 26}
, {@link #interpolated()}=true
.
*/
BITS_26_PER_13_INTERPOLATED(new int[]{13, 26}, true),
/**
* Here {@link #bitLevels()}={8, 16, 26}
, {@link #interpolated()}=false
.
*/
BITS_26_PER_8(new int[]{8, 16, 26}, false),
/**
* Here {@link #bitLevels()}={8, 16, 26}
, {@link #interpolated()}=true
.
*/
BITS_26_PER_8_INTERPOLATED(new int[]{8, 16, 26}, true),
/**
* Here {@link #bitLevels()}={6, 12, 18, 26}
, {@link #interpolated()}=false
.
*/
BITS_26_PER_6(new int[]{6, 12, 18, 26}, false),
/**
* Here {@link #bitLevels()}={6, 12, 18, 26}
, {@link #interpolated()}=true
.
*/
BITS_26_PER_6_INTERPOLATED(new int[]{6, 12, 18, 26}, true);
/*Repeat.AutoGeneratedEnd*/
final int[] bitLevels;
final boolean interpolated;
RankPrecision(int[] bitLevels, boolean interpolated) {
assert bitLevels.length > 0;
this.bitLevels = bitLevels;
this.interpolated = interpolated;
}
public int[] bitLevels() {
return bitLevels.clone();
}
public int numberOfAnalyzedBits() {
return bitLevels[bitLevels.length - 1];
}
public boolean interpolated() {
return interpolated;
}
/**
* Returns the enum instance with the same {@link #bitLevels() bit levels} and with the specified
* "{@link #interpolated() interpolated}" flag.
*
* If the argument is equal to the current result of {@link #interpolated()} method,
* returns the reference to this instance.
*
* @param interpolated new "interpolated" flag.
* @return the instance of this enum with the same {@link #bitLevels() bit levels} and
* the specified "{@link #interpolated() interpolated}" flag.
*/
public RankPrecision otherInterpolation(boolean interpolated) {
if (interpolated == this.interpolated) {
return this;
}
for (RankPrecision rp : values()) {
if (java.util.Arrays.equals(rp.bitLevels, this.bitLevels) && rp.interpolated == interpolated) {
return rp;
}
}
throw new InternalError("Illegal set of constants in " + getClass() + ": "
+ this + " has no partner with another interpolation flag \"" + interpolated + "\"");
}
}