Skip to content

Commit

Permalink
exception if xyshift is not even
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Goina committed Feb 29, 2024
1 parent 96c3341 commit eb63241
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ public class ColorDepthSearchAlgorithmProviderFactory {
* @param mirrorMask flag whether to use mirroring
* @param targetThreshold data threshold
* @param pixColorFluctuation z - gap tolerance - sometimes called pixel color fluctuation
* @param xyShift - x-y translation for searching for a match
* @param xyShiftParam x-y translation when searching for a match - this is an even number
* because a shift by 1 pixel is too small so we always shift by
* multiples of 2 pixels
* @return a color depth search search provider
*/
public static ColorDepthSearchAlgorithmProvider<PixelMatchScore> createPixMatchCDSAlgorithmProvider(
boolean mirrorMask,
int targetThreshold,
double pixColorFluctuation,
int xyShift,
int xyShiftParam,
ImageRegionDefinition ignoredRegionsProvider) {
LOG.info("Create mask comparator with mirrorQuery={}, dataThreshold={}, pixColorFluctuation={}, xyShift={}",
mirrorMask, targetThreshold, pixColorFluctuation, xyShift);
mirrorMask, targetThreshold, pixColorFluctuation, xyShiftParam);
return new ColorDepthSearchAlgorithmProvider<PixelMatchScore>() {
ColorDepthSearchParams defaultCDSParams = new ColorDepthSearchParams()
.setParam("mirrorMask", mirrorMask)
.setParam("dataThreshold", targetThreshold)
.setParam("pixColorFluctuation", pixColorFluctuation)
.setParam("xyShift", xyShift);
.setParam("xyShift", xyShiftParam);

@Override
public ColorDepthSearchParams getDefaultCDSParams() {
Expand All @@ -53,6 +55,10 @@ public ColorDepthSearchAlgorithm<PixelMatchScore> createColorDepthSearchAlgorith
ColorDepthSearchParams cdsParams) {
Double pixColorFluctuationParam = cdsParams.getDoubleParam("pixColorFluctuation", pixColorFluctuation);
double zTolerance = pixColorFluctuationParam == null ? 0. : pixColorFluctuationParam / 100;
int xyShift = cdsParams.getIntParam("xyShift", xyShiftParam);
if ((xyShift & 0x1) == 1) {
throw new IllegalArgumentException("XY shift parameter must be an even number.");
}
return new PixelMatchColorDepthSearchAlgorithm(
queryImageArray,
queryThreshold,
Expand All @@ -62,7 +68,7 @@ public ColorDepthSearchAlgorithm<PixelMatchScore> createColorDepthSearchAlgorith
false,
cdsParams.getIntParam("dataThreshold", targetThreshold),
zTolerance,
cdsParams.getIntParam("xyShift", xyShift),
xyShift,
ignoredRegionsProvider);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AbstractColorDepthMatchArgs extends AbstractCmdArgs {
@Parameter(names = {"--pixColorFluctuation"}, description = "Pix Color Fluctuation, 1.18 per slice")
Double pixColorFluctuation = 2.0;

@Parameter(names = {"--xyShift"}, description = "Number of pixels to try shifting in XY plane")
@Parameter(names = {"--xyShift"}, description = "Number of pixels to try shifting in XY plane. This must be an even natural number - typically: 0, 2, or 4")
Integer xyShift = 0;

@Parameter(names = {"--negativeRadius"}, description = "Radius for gradient based score adjustment (negative radius)")
Expand Down

0 comments on commit eb63241

Please sign in to comment.