Skip to content

Commit 2de5e66

Browse files
authored
Merge pull request #53 from tsipkens/patch-may24
Merge May 24 patch
2 parents cd661f0 + e5d4616 commit 2de5e66

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

+agg/seg.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@
181181
moreaggs = 0; % default, returned if 'Yes' is chosen
182182
if strcmp(choice,'Yes, but refine')
183183
choice2 = questdlg('How do you want to refine aggregate detection?',...
184-
'agg detection','More particles or add to existing particles', ...
184+
'agg detection','Interactive tool to adjust thresholding', ...
185185
'Remove particles','More particles or add to existing particles');
186186

187187
% If more particles, set moreaggs = 1, which will skip ahead to Line 131
188-
if strcmp(choice2, 'More particles or add to existing particles')
188+
if strcmp(choice2, 'Interactive tool to adjust thresholding')
189189
moreaggs = 1;
190190

191191
% If particles to remove, use the bwselect utility.

+agg/ui_slider2.mlapp

2.28 KB
Binary file not shown.

+tools/write_json.m

+11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11

2+
% WRITE_JSON Used to write structures for JSON files.
3+
% NOTE: Saving large aggregate structures can be slow.
4+
%
5+
% AUTHOR: Timothy Sipkens
26

37
function [t2,t0] = write_json(var, fname)
48

59
fid = fopen(fname,'wt'); % open file, overwriting previous text
610

11+
% Binary field of Aggs structure is sparse logical.
12+
% Convert of logical, as sparse structure cannot be stored.
13+
if isfield(var, 'binary')
14+
for ii=1:length(var)
15+
var(ii).binary = full(var(ii).binary);
16+
end
17+
end
718

819
%-- Encode json ----------------------------------------------------------%
920
t0 = jsonencode(var); % generate json text using built-in function

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ This code also includes a set of utility functions in the **+tools** package and
4343

4444
# A. Dependencies
4545

46-
This software was tested using MATLAB 2020a (though most functions have been validated against older versions) and depends on the following MATLAB toolboxes:
46+
This software was tested using MATLAB 2022a (though most functions have been validated against older versions). The current code depends on the following MATLAB toolboxes:
4747

4848
1. the curve fitting toolbox,
4949
2. the financial toolbox,
5050
3. the image toolbox,
5151
4. the optimization toolbox, and
52-
6. the video and image blockset (in the computer vision toolbox, which is used for OCR).
52+
5. the video and image blockset (in the computer vision toolbox, which is used for OCR).
5353

5454
If not already installed, these packages can be added to MATLAB via the instructions available on [MATLAB's website](https://www.mathworks.com/help/matlab/matlab_env/get-add-ons.html).
5555

@@ -64,7 +64,7 @@ The submodule is not necessary for any of the scripts or methods included with t
6464

6565
Additional dependencies are required for use of the **[carboseg](https://github.com/tsipkens/atems/tree/master/carboseg)** or convolutional neural network component of this program, including a copy of Python. See the appropriate [section below](#+-carboseg-and-cnn-segmentation) for more information.
6666

67-
This code has been tested on Windows. Linux users may have some issues with loading images when supplying a string to `tools.load_imgs(...)`.
67+
This code has been tested on Windows 10+. Linux users may have some issues with loading images when supplying a string to `tools.load_imgs(...)` (for example, because of differences in file separator). macOS users may encounter similar issues, including in writing aggregate structures to JSON files and in certain plotting functions.
6868

6969
# B. Getting started
7070

@@ -234,17 +234,17 @@ This `seg_carboseg(...)` function employs Python to implement a convolutional ne
234234
Details on the setup and use of this component are given in the [README](carboseg/README.md) in the **carboseg** subfolder. Two options exist for interacting with the Python code: (1) initializing an instance of Python directly in MATLAB or (2) a multi-step procedure of exporting and reimporting images.
235235

236236

237-
### + **seg_otsu_rb\*** / Otsu thresholding
237+
### + **seg_otsu\*** / Otsu thresholding
238238

239239
These automated methods apply Otsu thresholding followed by a rolling ball transformation. Two versions of this function are included.
240240

241-
**A.** The `agg.seg_otsu_rb_orig(...)` function remains more true to the original code of [Dastanpour et al. (2016)][dastanpour2016]. For the sample images, this often results in fragmented segmentations, e.g.,
241+
**A.** The `agg.seg_otsu_orig(...)` function remains more true to the original code of [Dastanpour et al. (2016)][dastanpour2016]. For the sample images, this often results in fragmented segmentations, e.g.,
242242

243243
![rb_orig](docs/otsu_rb_orig.png)
244244

245245
As the technique may be insufficient on its own, this implementation can be complimented with `agg.seg_slider(...)`, described [below](#-seg_slider_orig--gui-based-slider-method), to fill in the gaps between the aggregates and add missing aggregates.
246246

247-
**B.** Stemming from the deficiencies of the above function, the `agg.seg_otsu_rb(...)` function updates the above implementation by (*i*) not immediately removing boundary aggregates, (*ii*) adding a background subtraction step using the `agg.bg_subtract(...)` function, and (*iii*) adding a bilateral denoising step. This results in the following segmentations.
247+
**B.** Stemming from the deficiencies of the above function, the `agg.seg_otsu(...)` function updates the above implementation by (*i*) not immediately removing boundary aggregates, (*ii*) adding a background subtraction step using the `agg.bg_subtract(...)` function, and (*iii*) adding a bilateral denoising step. This results in the following segmentations.
248248

249249
![otsu_rb](docs/otsu_rb.png)
250250

@@ -294,11 +294,11 @@ Among the changes to the original EDM-SBS code, this implementation also applies
294294

295295
### + **kook\*** / Hough transform
296296

297-
Two `pp.kook*(...)` functions are included with this program, which fit circles to features in the image using the Hough transform and the pre-processing steps described by [Kook et al. (2015)][kook].
297+
Two `pp.hough_kook**(...)` functions are included with this program, which fit circles to features in the image using the Hough transform and the pre-processing steps described by [Kook et al. (2015)][kook].
298298

299-
The first function, `pp.kook(...)`, contains a copy of the code provided by [Kook et al. (2015)][kook], with minor modifications to match the input/output of some of the other packages — namely to take a single image, `img`, and a pixel size, `pixsize` — and to output a `Pp` structure, which contains information for each circle. Note that the original function acts on images without trying to assign primary particles to an aggregate, something resolved in the second function below. This causes some compatibility issues in terms of comparing the output from this function to the other methods contained in this program.
299+
The first function, `pp.hough_kook*(...)`, contains a copy of the code provided by [Kook et al. (2015)][kook], with minor modifications to match the input/output of some of the other packages — namely to take a single image, `img`, and a pixel size, `pixsize` — and to output a `Pp` structure, which contains information for each circle. Note that the original function acts on images without trying to assign primary particles to an aggregate, something resolved in the second function below. This causes some compatibility issues in terms of comparing the output from this function to the other methods contained in this program.
300300

301-
The `pp.kook2(...)` function contains a modified version of the method proposed by [Kook et al. (2015)][kook] that excludes circles in the background and assigns primary particles to aggregates. This is done rather simply: by checking if the center of the circles from the preceding procedure lie within the binary for a given aggregate. A sample output is as follows.
301+
The `pp.hough_kook2(...)` function contains a modified version of the method proposed by [Kook et al. (2015)][kook] that excludes circles in the background and assigns primary particles to aggregates. This is done rather simply: by checking if the center of the circles from the preceding procedure lie within the binary for a given aggregate. A sample output is as follows.
302302

303303
![kook2](docs/kook2.png)
304304

0 commit comments

Comments
 (0)