Reference
CounterMarking.density_map
CounterMarking.gui
CounterMarking.meanshow
CounterMarking.process_images
CounterMarking.randshow
CounterMarking.segment_image
CounterMarking.spots
CounterMarking.stimulus_index
CounterMarking.upperleft
CounterMarking.writexlsx
CounterMarking.density_map
— Methodnmarked = density_map(jldfile::AbstractString)
Given a JLD2 file jldfile
written by gui
, return an array nmarked
counting of the number of images with a urine spot in each pixel. Before counting, the images are flipped so that the stimulus segment is in the upper left corner.
CounterMarking.gui
— Methodgui(outbase, files)
gui(outbase, glob::GlobMatch)
Run the graphical user interface (GUI) for CounterMarking. Supply the base name of the output files (e.g., "my_results") and a list of image files to process (alternatively, supply a glob"pattern"
that matches just the files you want to process).
The GUI will display the images and their segmentation, and allow the user to select the segments corresponding to the stimulus (yellow) and marked spots. The results will be save to:
outbase.xlsx
: an Excel file with one sheet per image, containing summary statistics on the stimulus spot and the selected spots.outbase.jld2
: a JLD2 file with one dataset per image, containing the segmented image, the selected spots, and the stimulus segment.
The JLD2 file can be used by density_map
.
CounterMarking.meanshow
— Functionmeanshow(seg; kwargs...)
meanshow(img, seg; kwargs...)
Display a segmented image using the mean color of each segment. The version with img
displays the original image and the segmented image one atop the other, and zooming on one will zoom on the other.
CounterMarking.process_images
— Methodprocess_images(outfile::AbstractString, glob::GlobMatch; dirname=pwd())
process_images(outfile::AbstractString, glob::AbstractString; dirname=pwd())
Process all images with filenames matching glob
and save the results to outfile
. Each image will be a separate sheet in the Excel file.
Optionally specify the dirname
containing the images.
Examples
To process a collection of images in a different directory, and save the results to that same directory:
julia> process_images("2025-03-15/results.xlsx", glob"*.png"; dirname="2025-03-15")
CounterMarking.randshow
— Functionrandshow(seg; kwargs...)
randshow(img, seg; kwargs...)
Display a segmented image using random colors for each segment. The version with img
displays the original image and the segmented image one atop the other, and zooming on one will zoom on the other.
!!! note You must load the ImageView
package to use this function.
CounterMarking.segment_image
— Methodseg = segment_image(img; threshold=0.1, min_size=20)
Given an image img
, segment it into regions using a region growing algorithm. min_size
is the minimum number of pixels per segment, and threshold
determines how different two colors must be to be considered different segments. Larger threshold
values will result in fewer segments.
CounterMarking.spots
— Methodspotdict, stimulus = spots(seg; max_size_frac=0.1)
Given a segmented image seg
, return a Dict(idx => spot)
where idx
is the segment index and spot
is a Spot
object where spot.npixels
is the number of pixels in the segment and spot.centroid
is the centroid of the segment.
stimulus
is a Pair{Int, Spot}
where the first element is the index of the stimulus segment and the second element is the Spot
object for that segment.
Spots larger than max_size_frac * npixels
(default: 10% of the image) are ignored.
CounterMarking.stimulus_index
— Functionidx = stimulus_index(seg::SegmentedImage, colorproj = RGB(1, 1, -2))
Given a segmented image seg
, return the index of the segment that scores highest on the product of (1) projection (dot product) with colorproj
and (2) number of pixels.
CounterMarking.upperleft
— Methodspotdict_ul, stimulus_ul = upperleft(spotdict::AbstractDict{Int, Spot}, stimulus, imgsize)
Given a spotdict
of Spot
objects and a stimulus
segment, return a new spotdict_ul
corresponding to an image flipped so that stimulus_ul
is in the upper left corner.
CounterMarking.writexlsx
— Methodwritexlsx(filename::AbstractString, seg::SegmentedImage)
Save the segmented image data to an Excel file.