Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
4e3cc252
Commit
4e3cc252
authored
Sep 07, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added testing for local max
parent
a656136c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
8 deletions
+58
-8
Differentials_.java
src/main/java/epfl/Differentials_.java
+58
-8
No files found.
src/main/java/epfl/Differentials_.java
View file @
4e3cc252
...
@@ -3,6 +3,7 @@ package epfl;
...
@@ -3,6 +3,7 @@ package epfl;
| Version: April 6, 2014
| Version: April 6, 2014
\=====================================================================*/
\=====================================================================*/
import
java.util.Arrays
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
/*=====================================================================
/*=====================================================================
...
@@ -82,6 +83,7 @@ public final static int NORMALIZE_LMAX = 9;
...
@@ -82,6 +83,7 @@ public final static int NORMALIZE_LMAX = 9;
public
final
static
int
LOCAL_MIN
=
10
;
// local minimum within radius
public
final
static
int
LOCAL_MIN
=
10
;
// local minimum within radius
public
final
static
int
LOCAL_MAX
=
11
;
// local maximum within radius
public
final
static
int
LOCAL_MAX
=
11
;
// local maximum within radius
public
final
static
int
LOCAL_DIFF
=
12
;
// local maximum - local minimum within radius
public
final
static
int
LOCAL_DIFF
=
12
;
// local maximum - local minimum within radius
public
final
static
int
LOCAL_ISMAX
=
13
;
// 1.0 if it is a local max, 0 - otherwise
private
final
static
int
THREADS_MAX
=
100
;
private
final
static
int
THREADS_MAX
=
100
;
...
@@ -114,7 +116,8 @@ private static String[] operations = {
...
@@ -114,7 +116,8 @@ private static String[] operations = {
"Normalize by local maximum"
,
"Normalize by local maximum"
,
"Local min"
,
"Local min"
,
"Local max"
,
"Local max"
,
"Local diff"
"Local diff"
,
"Local ismax"
};
};
/*....................................................................
/*....................................................................
...
@@ -369,7 +372,55 @@ private void doIt (
...
@@ -369,7 +372,55 @@ private void doIt (
if
(!(
ip
.
getPixels
()
instanceof
float
[]))
{
if
(!(
ip
.
getPixels
()
instanceof
float
[]))
{
throw
new
IllegalArgumentException
(
"Float image required"
);
throw
new
IllegalArgumentException
(
"Float image required"
);
}
}
switch
(
operation
)
{
switch
(
operation
)
{
// for positive values only
case
LOCAL_ISMAX:
{
final
float
[]
floatPixels
=
(
float
[])
ip
.
getPixels
();
final
double
[]
pixels
=
new
double
[
floatPixels
.
length
];
for
(
int
i
=
0
;
i
<
pixels
.
length
;
i
++)
{
pixels
[
i
]
=
floatPixels
[
i
];
}
Arrays
.
fill
(
floatPixels
,
0.0f
);
final
Thread
[]
threads
=
newThreadArray
(
THREADS_MAX
);
final
AtomicInteger
ai
=
new
AtomicInteger
(
0
);
for
(
int
y00
=
0
;
(
y00
<
height
);
y00
++)
{
final
int
y0
=
y00
;
int
ymin
=
Math
.
max
(
y0
-
1
,
0
);
int
ymax
=
Math
.
min
(
y0
+
1
,
height
-
1
);
ai
.
set
(
0
);
for
(
int
ithread
=
0
;
ithread
<
threads
.
length
;
ithread
++)
{
threads
[
ithread
]
=
new
Thread
()
{
public
void
run
()
{
for
(
int
x0
=
ai
.
getAndIncrement
();
x0
<
width
;
x0
=
ai
.
getAndIncrement
())
{
int
k
=
y0
*
width
+
x0
;
int
xmin
=
Math
.
max
(
x0
-
1
,
0
);
int
xmax
=
Math
.
min
(
x0
+
1
,
width
-
1
);
double
d
=
pixels
[
k
];
if
(
d
>
0
)
{
maxtest:
{
for
(
int
y
=
ymin
;
y
<=
ymax
;
y
++)
{
for
(
int
x
=
xmin
;
x
<=
xmax
;
x
++)
{
int
dx
=
x
-
x0
;
int
dy
=
y
-
y0
;
if
(
pixels
[
y
*
width
+
x
]
>
d
)
{
break
maxtest
;
}
}
}
floatPixels
[
k
]
=
1.0f
;
}
}
}
}
};
}
startAndJoin
(
threads
);
stepProgressBar
();
}
}
break
;
case
LOCAL_DIFF:
case
LOCAL_DIFF:
{
{
final
int
ir
=
(
int
)
Math
.
ceil
(
max_norm_rad
);
final
int
ir
=
(
int
)
Math
.
ceil
(
max_norm_rad
);
...
@@ -422,8 +473,6 @@ private void doIt (
...
@@ -422,8 +473,6 @@ private void doIt (
}
}
break
;
break
;
case
LOCAL_MIN:
case
LOCAL_MIN:
{
{
final
int
ir
=
(
int
)
Math
.
ceil
(
max_norm_rad
);
final
int
ir
=
(
int
)
Math
.
ceil
(
max_norm_rad
);
...
@@ -934,6 +983,7 @@ private void setupProgressBar (
...
@@ -934,6 +983,7 @@ private void setupProgressBar (
completed
=
0
;
completed
=
0
;
lastTime
=
System
.
currentTimeMillis
();
lastTime
=
System
.
currentTimeMillis
();
switch
(
operation
)
{
switch
(
operation
)
{
case
LOCAL_ISMAX:
case
LOCAL_MIN:
case
LOCAL_MIN:
case
LOCAL_MAX:
case
LOCAL_MAX:
case
LOCAL_DIFF:
case
LOCAL_DIFF:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment