Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sbalzarini Lab
S
Software
Bio-Imaging
MosaicSuite
Commits
55cad709
Commit
55cad709
authored
Aug 08, 2018
by
Krzysztof Gonciarz
Browse files
Tests added for BackgroundSubtracktor
parent
df7a40f0
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/main/java/mosaic/plugins/BackgroundSubtractor2_.java
View file @
55cad709
...
...
@@ -8,6 +8,8 @@ import java.awt.event.ActionEvent;
import
java.awt.event.ActionListener
;
import
java.util.Vector
;
import
org.apache.log4j.Logger
;
import
ij.IJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
...
...
@@ -22,8 +24,6 @@ import ij.process.ImageProcessor;
import
ij.process.ImageStatistics
;
import
ij.process.ShortProcessor
;
import
mosaic.core.utils.MosaicUtils
;
import
org.apache.log4j.Logger
;
import
org.scijava.log.LogService
;
/**
...
...
@@ -72,14 +72,7 @@ public class BackgroundSubtractor2_ implements PlugInFilter, ActionListener{
@Override
public
int
setup
(
String
aArgs
,
ImagePlus
aImagePlus
){
if
(
IJ
.
versionLessThan
(
"1.36x"
))
{
return
DONE
;
}
if
(
aImagePlus
==
null
)
{
IJ
.
showMessage
(
"Load an image first."
);
return
DONE
;
}
// Read macro options
final
String
options
=
Macro
.
getOptions
();
logger
.
info
(
"Macro Options: ["
+
options
+
"]"
);
if
(
options
!=
null
)
{
...
...
@@ -103,9 +96,11 @@ public class BackgroundSubtractor2_ implements PlugInFilter, ActionListener{
while
(
vWhatToDo
==
2
){
vWhatToDo
=
showDialog
();
if
(
vWhatToDo
==
0
)
{
logger
.
debug
(
"Plugin canceled."
);
return
DONE
;
}
if
(
vWhatToDo
==
1
)
{
logger
.
debug
(
"Plugin OKed."
);
break
;
}
}
...
...
@@ -124,7 +119,7 @@ public class BackgroundSubtractor2_ implements PlugInFilter, ActionListener{
* Subtracts the background for the processor in the argument.
*/
@Override
public
void
run
(
ImageProcessor
aImageProcessor
){
public
void
run
(
ImageProcessor
aImageProcessor
)
{
int
vType
;
if
(
aImageProcessor
instanceof
ByteProcessor
)
{
vType
=
BYTE
;
...
...
@@ -147,6 +142,9 @@ public class BackgroundSubtractor2_ implements PlugInFilter, ActionListener{
return
;
}
}
logger
.
debug
(
"Running with mOriginalImagePlus="
+
mOriginalImagePlus
.
getTitle
()
+
" lenght="
+
mLength
+
" bins="
+
mBins
+
" api="
+
mAPICall
+
" doAll="
+
mDoAll
);
int
vStartSlice
=
0
;
int
vStopSlice
=
0
;
if
(!
mAPICall
)
{
...
...
@@ -288,13 +286,16 @@ public class BackgroundSubtractor2_ implements PlugInFilter, ActionListener{
case
BYTE:
vImageProcessor
=
vImageProcessor
.
convertToByte
(
false
);
vOrigImageProcessor
.
insert
(
vImageProcessor
,
0
,
0
);
logger
.
debug
(
"Putting back BYTE processor"
);
break
;
case
SHORT:
vImageProcessor
=
vImageProcessor
.
convertToShort
(
false
);
vOrigImageProcessor
.
insert
(
vImageProcessor
,
0
,
0
);
logger
.
debug
(
"Putting back SHORT processor"
);
break
;
case
FLOAT:
vOrigImageProcessor
.
insert
(
vImageProcessor
,
0
,
0
);
logger
.
debug
(
"Putting back FLOAT processor"
);
break
;
default
:
// Should not happen
...
...
src/test/java/mosaic/plugins/BackgroundSubtractor2_Test.java
0 → 100644
View file @
55cad709
package
mosaic.plugins
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
mosaic.test.framework.CommonBase
;
public
class
BackgroundSubtractor2_Test
extends
CommonBase
{
@Test
public
void
testFixedLength
()
{
// run("Background Subtractor", "length=10 show skipOnFailure");
// Define test data
final
String
tcDirName
=
"BackgroundSubtractor/fixedLength/"
;
final
String
setupString
=
""
;
final
String
macroOptions
=
"length=4"
;
final
String
inputFile
=
"test.tif"
;
final
String
[]
expectedImgFiles
=
{
"test.tif"
};
final
String
[]
referenceImgFiles
=
{
"testOutput.tif"
};
final
String
[]
expectedFiles
=
{};
final
String
[]
referenceFiles
=
{};
// Create tested plugIn
final
BackgroundSubtractor2_
plugin
=
new
BackgroundSubtractor2_
();
// Test it
testPlugin
(
plugin
,
tcDirName
,
macroOptions
,
setupString
,
inputFile
,
expectedImgFiles
,
referenceImgFiles
,
expectedFiles
,
referenceFiles
);
}
@Test
public
void
testFixedLengthBG
()
{
// Define test data
final
String
tcDirName
=
"BackgroundSubtractor/fixedLength/"
;
final
String
setupString
=
""
;
final
String
macroOptions
=
"length=4 show"
;
final
String
inputFile
=
"test.tif"
;
final
String
[]
expectedImgFiles
=
{
"test.tif"
,
"BG of test.tif"
};
final
String
[]
referenceImgFiles
=
{
"testOutput.tif"
,
"testOutputBG.tif"
};
final
String
[]
expectedFiles
=
{};
final
String
[]
referenceFiles
=
{};
// Create tested plugIn
final
BackgroundSubtractor2_
plugin
=
new
BackgroundSubtractor2_
();
// Test it
testPlugin
(
plugin
,
tcDirName
,
macroOptions
,
setupString
,
inputFile
,
expectedImgFiles
,
referenceImgFiles
,
expectedFiles
,
referenceFiles
);
}
@Test
public
void
testAutoLength
()
{
// run("Background Subtractor", "length=10 show skipOnFailure");
// Define test data
final
String
tcDirName
=
"BackgroundSubtractor/autoLength/"
;
final
String
setupString
=
""
;
final
String
macroOptions
=
"length=-1"
;
final
String
inputFile
=
"test.tif"
;
final
String
[]
expectedImgFiles
=
{
"test.tif"
};
final
String
[]
referenceImgFiles
=
{
"testOutput.tif"
};
final
String
[]
expectedFiles
=
{};
final
String
[]
referenceFiles
=
{};
// Create tested plugIn
final
BackgroundSubtractor2_
plugin
=
new
BackgroundSubtractor2_
();
// Test it
testPlugin
(
plugin
,
tcDirName
,
macroOptions
,
setupString
,
inputFile
,
expectedImgFiles
,
referenceImgFiles
,
expectedFiles
,
referenceFiles
);
}
}
src/test/java/mosaic/test/framework/CommonBase.java
View file @
55cad709
...
...
@@ -139,6 +139,7 @@ public class CommonBase extends Info {
if
(
aInputFile
!=
null
)
{
logger
.
debug
(
"Loading image for testing: ["
+
tmpPath
+
aInputFile
+
"]"
);
final
ImagePlus
ip
=
loadImagePlus
(
tmpPath
+
aInputFile
);
ip
.
show
();
logger
.
debug
(
"Testing plugin"
);
WindowManager
.
setTempCurrentImage
(
ip
);
}
...
...
src/test/resources/BackgroundSubtractor/autoLength/test.tif
0 → 100644
View file @
55cad709
File added
src/test/resources/BackgroundSubtractor/autoLength/testOutput.tif
0 → 100644
View file @
55cad709
File added
src/test/resources/BackgroundSubtractor/fixedLength/test.tif
0 → 100644
View file @
55cad709
File added
src/test/resources/BackgroundSubtractor/fixedLength/testOutput.tif
0 → 100644
View file @
55cad709
File added
src/test/resources/BackgroundSubtractor/fixedLength/testOutputBG.tif
0 → 100644
View file @
55cad709
File added
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