Skip to content

Commit 5522880

Browse files
author
Bobafotz
committed
Rename pixel_distance to radius
1 parent ea5fc60 commit 5522880

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/main/java/net/haesleinhuepf/clijx/plugins/GenerateGreyValueCooccurrenceMatrixBox.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public boolean executeCL() {
2626
return result;
2727
}
2828

29-
public static boolean generateGreyValueCooccurrenceMatrixBox(CLIJ2 clij2, ClearCLBuffer src, ClearCLBuffer dst_cooccurrence_matrix, Float minimum_intensity, Float maximum_intensity, int pixel_distance) {
29+
public static boolean generateGreyValueCooccurrenceMatrixBox(CLIJ2 clij2, ClearCLBuffer src, ClearCLBuffer dst_cooccurrence_matrix, Float minimum_intensity, Float maximum_intensity, int radius) {
3030
ClearCLBuffer flip = clij2.create(src.getDimensions(), NativeTypeEnum.Float);
3131
ClearCLBuffer flop = clij2.create(src.getDimensions(), NativeTypeEnum.Float);
3232

@@ -37,7 +37,7 @@ public static boolean generateGreyValueCooccurrenceMatrixBox(CLIJ2 clij2, ClearC
3737

3838
ClearCLBuffer temp_matrix = clij2.create(dst_cooccurrence_matrix.getDimensions(), NativeTypeEnum.Float);
3939

40-
GenerateIntegerGreyValueCooccurrenceCountMatrixHalfBox.generateIntegerGreyValueCooccurrenceCountMatrixHalfBox(clij2, flip, temp_matrix, pixel_distance);
40+
GenerateIntegerGreyValueCooccurrenceCountMatrixHalfBox.generateIntegerGreyValueCooccurrenceCountMatrixHalfBox(clij2, flip, temp_matrix, radius);
4141
double sum = clij2.sumOfAllPixels(temp_matrix);
4242

4343
clij2.multiplyImageAndScalar(temp_matrix, dst_cooccurrence_matrix, 1.0 / sum);
@@ -50,7 +50,7 @@ public static boolean generateGreyValueCooccurrenceMatrixBox(CLIJ2 clij2, ClearC
5050

5151
@Override
5252
public String getParameterHelpText() {
53-
return "Image integer_image, ByRef Image grey_value_cooccurrence_matrix_destination, Number min_grey_value, Number max_grey_value, Number pixel_distance";
53+
return "Image integer_image, ByRef Image grey_value_cooccurrence_matrix_destination, Number min_grey_value, Number max_grey_value, Number radius";
5454
}
5555

5656

src/main/java/net/haesleinhuepf/clijx/plugins/GenerateIntegerGreyValueCooccurrenceCountMatrixHalfBox.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public boolean executeCL() {
2626
return result;
2727
}
2828

29-
public static boolean generateIntegerGreyValueCooccurrenceCountMatrixHalfBox(CLIJ2 clij2, ClearCLBuffer src_label_map1, ClearCLBuffer dst_cooccurrence_matrix, int pixel_distance) {
29+
public static boolean generateIntegerGreyValueCooccurrenceCountMatrixHalfBox(CLIJ2 clij2, ClearCLBuffer src_label_map1, ClearCLBuffer dst_cooccurrence_matrix, int radius) {
3030
int num_threads = (int) src_label_map1.getDepth();
3131

3232
long[][][] counts = new long[num_threads][(int)dst_cooccurrence_matrix.getWidth()][(int)dst_cooccurrence_matrix.getHeight()];
@@ -62,7 +62,7 @@ public static boolean generateIntegerGreyValueCooccurrenceCountMatrixHalfBox(CLI
6262
}
6363

6464

65-
statisticians[i] = new Statistician(counts[i], image_slice, image_next_slice, (int)src_label_map1.getWidth(), (int)src_label_map1.getHeight(), (int)pixel_distance);
65+
statisticians[i] = new Statistician(counts[i], image_slice, image_next_slice, (int)src_label_map1.getWidth(), (int)src_label_map1.getHeight(), (int)radius);
6666
threads[i] = new Thread(statisticians[i]);
6767
threads[i].start();
6868
}
@@ -107,53 +107,53 @@ public String getCategories() {
107107
private static class Statistician implements Runnable{
108108
private final int width;
109109
private final int height;
110-
private final int pixel_distance;
110+
private final int radius;
111111

112112
long[][] counts;
113113

114114
private float[] image;
115115
private float[] image_next_slice;
116116

117-
Statistician(long[][] counts, float[] image, float[] image_next_slice, int width, int height, int pixel_distance) {
117+
Statistician(long[][] counts, float[] image, float[] image_next_slice, int width, int height, int radius) {
118118
this.counts = counts;
119119
this.image = image;
120120
this.image_next_slice = image_next_slice;
121121
this.width = width;
122122
this.height = height;
123-
this.pixel_distance = pixel_distance;
123+
this.radius = radius;
124124
}
125125

126126
@Override
127127
public void run() {
128128

129129
int x = 0;
130130
int y = 0;
131-
for (int i = 0; i < image.length - pixel_distance; i++) {
131+
for (int i = 0; i < image.length - radius; i++) {
132132
int value_1 = (int) image[i];
133133
int value_2;
134134

135135
// right
136-
if (x < width - pixel_distance) {
137-
value_2 = (int) image[i + pixel_distance];
136+
if (x < width - radius) {
137+
value_2 = (int) image[i + radius];
138138
counts[value_1][value_2]++;
139139
counts[value_2][value_1]++;
140140
}
141141
// bottom
142-
if (y < height - pixel_distance) {
143-
value_2 = (int) image[i + (width * pixel_distance)];
142+
if (y < height - radius) {
143+
value_2 = (int) image[i + (width * radius)];
144144
counts[value_1][value_2]++;
145145
counts[value_2][value_1]++;
146146
}
147147
// bottom, right
148-
if (x < width - pixel_distance && y < height - pixel_distance) {
149-
value_2 = (int) image[i + (width * pixel_distance) + pixel_distance];
148+
if (x < width - radius && y < height - radius) {
149+
value_2 = (int) image[i + (width * radius) + radius];
150150
counts[value_1][value_2]++;
151151
counts[value_2][value_1]++;
152152
}
153153

154154
// top, right
155-
if (y > pixel_distance && x < (width * pixel_distance) - pixel_distance) {
156-
value_2 = (int) image[i - (width * pixel_distance) + pixel_distance];
155+
if (y > radius && x < (width * radius) - radius) {
156+
value_2 = (int) image[i - (width * radius) + radius];
157157
counts[value_1][value_2]++;
158158
counts[value_2][value_1]++;
159159
}
@@ -162,12 +162,12 @@ public void run() {
162162
if (image_next_slice != null) {
163163
for (int delta_x = -1; delta_x <= 1; delta_x ++) {
164164
for (int delta_y = -1; delta_y <= 1; delta_y ++) {
165-
int index = i + delta_x + width * pixel_distance * delta_y;
166-
if (x + delta_x < width * pixel_distance &&
165+
int index = i + delta_x + width * radius * delta_y;
166+
if (x + delta_x < width * radius &&
167167
x - delta_x >= 0 &&
168-
y + delta_y < height * pixel_distance &&
168+
y + delta_y < height * radius &&
169169
y - delta_y >= 0 &&
170-
index >= 0 && index < image_next_slice.length - pixel_distance) {
170+
index >= 0 && index < image_next_slice.length - radius) {
171171
value_2 = (int) image_next_slice[index];
172172
counts[value_1][value_2]++;
173173
counts[value_2][value_1]++;
@@ -177,7 +177,7 @@ public void run() {
177177
}
178178

179179
x++;
180-
if (x >= width - pixel_distance) {
180+
if (x >= width - radius) {
181181
x = 0;
182182
y++;
183183
}

0 commit comments

Comments
 (0)