Skip to content

Commit

Permalink
Chart Tool - add option to list chart vertices #43
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsacha committed Sep 2, 2021
1 parent 3af1b12 commit 5f07a33
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ijp-color-ui/src/main/resources/plugins.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Plugins>Color, "IJP Color Calculator...", ij_plugins.color.ui.converter.ColorConverterPlugin
Plugins>Color, "IJP Color Calibrator...", ij_plugins.color.ui.calibration.ColorCalibratorPlugin
Plugins>Color, "IJP Color Chart Tool...", ij_plugins.color.ui.util.ColorChartToolPlugin
Plugins>Color, "IJP Color Chart Tool...", ij_plugins.color.ui.charttool.ColorChartToolPlugin
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
* Latest release available at https://github.com/ij-plugins/ijp-color/
*/

package ij_plugins.color.ui.util
package ij_plugins.color.ui.charttool

import ij.gui._
import ij.measure.ResultsTable
import ij.plugin.PlugIn
import ij.process.ImageStatistics
import ij.{IJ, ImagePlus}
import ij_plugins.color.calibration.chart.{GridChartFrame, GridChartFrameUtils}
import ij_plugins.color.ui.util.{IJPUtils, ImageListenerHelper, LiveChartROI, LiveChartROIHelper}
import ij_plugins.color.util.{IJTools, PerspectiveTransform}
import scalafx.beans.property.ObjectProperty

Expand All @@ -38,7 +39,8 @@ import scala.collection.immutable.ListMap
object ColorChartToolPlugin {

private var sendToROIManager: Boolean = true
private var measureChips: Boolean = true
private var measureChips: Boolean = true
private var listChipVertices: Boolean = false
}

/**
Expand Down Expand Up @@ -97,6 +99,10 @@ class ColorChartToolPlugin extends PlugIn with DialogListener with ImageListener
if (measureChips) {
doMeasureChips(imp, chart)
}

if (listChipVertices) {
doListChipVertices(imp.getTitle, chart)
}
}
}

Expand All @@ -110,6 +116,8 @@ class ColorChartToolPlugin extends PlugIn with DialogListener with ImageListener
addMessage("")
addCheckbox("Send chip ROI to ROI Manager", sendToROIManager)
addCheckbox("Measure chips", measureChips)
addCheckbox("List_chip_vertices", listChipVertices)

addHelp("https://github.com/ij-plugins/ijp-color/wiki/Color-Chart-ROI-Tool")
}
gd.addDialogListener(this)
Expand Down Expand Up @@ -142,6 +150,7 @@ class ColorChartToolPlugin extends PlugIn with DialogListener with ImageListener

sendToROIManager = gd.getNextBoolean
measureChips = gd.getNextBoolean
listChipVertices = gd.getNextBoolean

chartOption.nonEmpty
}
Expand Down Expand Up @@ -186,17 +195,33 @@ class ColorChartToolPlugin extends PlugIn with DialogListener with ImageListener
}
}

rt.show("Chip Measurements")
rt.show(imp.getTitle + " - Chip Measurements")
}

private def doListChipVertices(imageTitle: String, chart: GridChartFrame): Unit = {
val rt = new ResultsTable()

chart.alignedChipROIs.foreach { roi =>
rt.incrementCounter()
rt.addValue("Chip", roi.getName)
val poly = roi.getPolygon
for (i <- 0 until poly.npoints) {
rt.addValue(s"x$i", poly.xpoints(i))
rt.addValue(s"y$i", poly.ypoints(i))
}
}

rt.show(imageTitle + " - Chip Vertices")
}

private def statsToMap(stats: ImageStatistics): ListMap[String, Double] = {
ListMap(
"Area" -> stats.area,
"Mean" -> stats.mean,
"Median" -> stats.median,
"Min" -> stats.min,
"Max" -> stats.max,
"StdDev" -> stats.stdDev,
"Area" -> stats.area,
"Mean" -> stats.mean,
"Median" -> stats.median,
"Min" -> stats.min,
"Max" -> stats.max,
"StdDev" -> stats.stdDev,
"Kurtosis" -> stats.kurtosis,
"Skewness" -> stats.skewness
)
Expand Down

0 comments on commit 5f07a33

Please sign in to comment.