From f7f6cf980f8bfd3614d94c1fe6d39bad45d97397 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Tue, 9 Nov 2021 08:50:59 -0500 Subject: [PATCH 1/3] Fix issue with incorrect computation of LinearNoInterceptCrossBand mapping #58 --- .../regression/MappingFactory.scala | 2 +- .../regression/MappingFactoryTest.scala | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ijp-color/src/main/scala/ij_plugins/color/calibration/regression/MappingFactory.scala b/ijp-color/src/main/scala/ij_plugins/color/calibration/regression/MappingFactory.scala index a28e1de..6c421cd 100644 --- a/ijp-color/src/main/scala/ij_plugins/color/calibration/regression/MappingFactory.scala +++ b/ijp-color/src/main/scala/ij_plugins/color/calibration/regression/MappingFactory.scala @@ -133,7 +133,7 @@ object MappingFactory { require(rr.beta.length == 3, "Size of beta must be equal 3, got " + rr.beta.length) val alpha14 = new Array[Double](14) - alpha14(1) = rr.beta(0) + rr.beta.copyToArray(alpha14, 1) new CubicPolynomial(alpha14, Option(rr)) } diff --git a/ijp-color/src/test/scala/ij_plugins/color/calibration/regression/MappingFactoryTest.scala b/ijp-color/src/test/scala/ij_plugins/color/calibration/regression/MappingFactoryTest.scala index c761727..47b53c9 100644 --- a/ijp-color/src/test/scala/ij_plugins/color/calibration/regression/MappingFactoryTest.scala +++ b/ijp-color/src/test/scala/ij_plugins/color/calibration/regression/MappingFactoryTest.scala @@ -66,6 +66,54 @@ class MappingFactoryTest extends AnyFlatSpec { cp.regressionResult.get.rSquared should be(0.9931 +- 0.0001) } + it should "createLinearNoInterceptXBand (for a band)" in { + + // Values based on "IMG_0903_025p-crop.tif" + // Chip margin: 16 + // Band: red (0) + // Chips with negative standard values excluded (21 of 24 chips used) + + val standard = Array(126.91979030350699, 216.20834154788753, 65.59369249416655, 98.31654126463174, + 118.2264657620243, 79.14341258243843, 242.05769847504052, 217.36207592151652, 88.1513891672125, + 177.94611517624423, 252.25703548744028, 83.31632229886839, 204.2661490485881, 265.5540885367791, + 204.39823118845072, 248.2796227241613, 201.91675592164282, 160.56106457681673, 117.76955679703373, + 83.66445997737526, 49.37241240933231) + val observed = Array( + Array(50.0181598062954, 20.692493946731236, 6.2941888619854724), + Array(123.94199243379572, 60.84741488020177, 43.90668348045397), + Array(52.774739583333336, 48.147135416666664, 55.24609375), + Array(49.07827260458839, 45.76923076923077, 3.4116059379217276), + Array(80.11018131101812, 56.83682008368201, 76.83124128312413), + Array(70.71551724137932, 104.76867816091954, 77.96120689655173), + Array(129.9434832756632, 48.10957324106113, 6.1280276816609), + Array(122.0730198019802, 31.084158415841586, 27.407178217821784), + Array(34.896153846153844, 13.28974358974359, 25.8), + Array(111.19521912350598, 106.04780876494024, 0.0), + Array(159.51440329218107, 89.1673525377229, 0.0), + Array(42.25541619156214, 64.54161915621437, 4.850627137970354), + Array(101.95985832349469, 20.65289256198347, 14.334120425029516), + Array(166.38536585365853, 109.20487804878049, 0.0), + Array(118.84702907711757, 41.25031605562579, 65.6826801517067), + Array(160.03979057591624, 124.83769633507853, 102.07748691099476), + Array(130.071661237785, 99.51031487513572, 81.14332247557003), + Array(101.88004484304933, 76.65807174887892, 62.26569506726457), + Array(71.38675958188153, 50.54239256678281, 37.92566782810685), + Array(42.70169082125604, 29.83816425120773, 21.544685990338163), + Array(15.848180677540778, 5.183186951066499, 2.986198243412798) + ) + + val expectedResult = Array(0.0, 1.9724784162678572, -0.426914583530878, -0.1296547005685931, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) + + val cp = MappingFactory.createLinearNoInterceptXBand(standard, observed) + val cpArray = cp.toArray + + cpArray should be(expectedResult) + + cp.regressionResult.isDefined should be(true) + cp.regressionResult.get.rSquared should be(0.991 +- 0.001) + } + it should "createLinear" in { val observed = Array(1, 1.5, 2, 3, 4, 5, 7, 10) val standard = From 6eddb57658dcbbc7f0ef31d437acd1ef4fb58c28 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Tue, 9 Nov 2021 08:53:19 -0500 Subject: [PATCH 2/3] Fixed spelling mistake in UI #59 --- .../ij_plugins/color/ui/calibration/ColorCalibrator.fxml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ijp-color-ui/src/main/resources/ij_plugins/color/ui/calibration/ColorCalibrator.fxml b/ijp-color-ui/src/main/resources/ij_plugins/color/ui/calibration/ColorCalibrator.fxml index 5d6430e..1e30047 100644 --- a/ijp-color-ui/src/main/resources/ij_plugins/color/ui/calibration/ColorCalibrator.fxml +++ b/ijp-color-ui/src/main/resources/ij_plugins/color/ui/calibration/ColorCalibrator.fxml @@ -97,7 +97,7 @@