locked-fg / jfeaturelib Goto Github PK
View Code? Open in Web Editor NEWFree Java library for image features and point/region detectors used in ComputerVision
Free Java library for image features and point/region detectors used in ComputerVision
I am beginner at jfeaturelib and i want to use Gabor Filter and i am getting "NoClassDefFoundError: at/lux/imageanalysis/VisualDescriptor" error
my code-
package TextureFeature;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import javax.imageio.ImageIO;
import de.lmu.ifi.dbs.jfeaturelib.features.Gabor;
import de.lmu.ifi.dbs.jfeaturelib.features.Haralick;
import de.lmu.ifi.dbs.utilities.Arrays2;
import ij.process.ColorProcessor;
class GaborFilter {
public static void main(String[] args) throws IOException, URISyntaxException {
// load the image
String path="C:\Users\D\Downloads\CBIR\images\first.jpg";
File stream =new File(path);
//InputStream stream = HaralickDemo.class.getClassLoader().getResourceAsStream("test.jpg");
ColorProcessor image = new ColorProcessor(ImageIO.read(stream));
// initialize the descriptor
Gabor descriptor =new Gabor();
//Haralick descriptor = new Haralick();
// run the descriptor and extract the features
descriptor.run(image);
// obtain the features
List<double[]> features = descriptor.getFeatures();
// print the features to system out
for (double[] feature : features) {
System.out.println(Arrays2.join(feature, ", ", "%.5f"));
}
}
}
Computing the variance via (E(X)^2 - E(X^2)) as done e.g. in Haralick.java, function meanVar is numerically unstable, in particular when the mean is not zero, due to catastrophic cancellation. It also is biased, but that shouldn't make much of a difference.
For details (and stable algorithms; the two-pass algorithm is simplest and should work well enough here), see e.g.:
https://en.wikipedia.org/wiki/Algebraic_formula_for_the_variance
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
and, of course, Knuth "The Art of Computer Programming".
private double[] meanVar(double[] a) {
// two-pass is numerically stable.
// don't use E(X)^2-E(X^2)!
double ex = 0;
for (int i = 0; i < NUM_GRAY_VALUES; i++) {
ex += a[i];
}
ex /= a.length;
double ex2 = 0;
for (int i = 0; i < NUM_GRAY_VALUES; i++) {
ex2 += (a[i] - ex) * (a[i] - ex);
}
ex2 /= (a.length - 1);
return new double[]{ex, ex2};
}
There might be other numerical loss problems occurring in Haralick, due to the various ever-growing sums and sums-of-squares. Kahan summation might also be a good idea to use, too.
And of course, similar numerical issues might be in other parts of jFeaturelib...
A threading issue was caused by static code in JFeatureLib Coloprocessor.
Starting with ImageJ 1.48a there is a non static setRGBWeights method.
Using this method, the copied code can be removed again.
http://imagej.1557.x6.nabble.com/Race-condition-in-ColorProcessor-td5003974.html
The shape descriptors only accept binarized images.
It should be thought about changing it to Supports.BINARY (which must be introduced)
Maybe it should be thought about pulling the automatic-conversion out of the extractors into a separate class.
What I have did?
Using jar JFeatureLib-1.6.3-jar-with-dependencies.jar
and following command
java -jar JFeatureLib-1.6.3-jar-with-dependencies.jar -D Sift -d F:\eZen\Swapnil\images -o F:\eZen\Swapnil\op\opp1.csv
same query is working for CEED
What was expected ?
SIFT values for each image in images folder in opp1.csv file.
What I am getting ?
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: jFeatureLib.log (Access is denied)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.(FileOutputStream.java:213)
at java.io.FileOutputStream.(FileOutputStream.java:133)
at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java
:207)
at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:3
07)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigura
tor.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigura
tor.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyC
onfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionCon
verter.java:526)
at org.apache.log4j.LogManager.(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor.(Extractor.java:79
)
0 WARN [pool-1-thread-2] de.lmu.ifi.dbs.jfeaturelib.features.Sift - Sift
Binary not executable: sift.exe
java.io.IOException: Sift Binary not executable: sift.exe
at de.lmu.ifi.dbs.jfeaturelib.features.sift.SiftWrapper.(SiftWrapp
er.java:66)
at de.lmu.ifi.dbs.jfeaturelib.features.Sift.run(Sift.java:114)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor$ExtractionTask.run(Extract
or.java:633)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
0 WARN [pool-1-thread-3] de.lmu.ifi.dbs.jfeaturelib.features.Sift - Sift
Binary not executable: sift.exe
java.io.IOException: Sift Binary not executable: sift.exe
at de.lmu.ifi.dbs.jfeaturelib.features.sift.SiftWrapper.(SiftWrapp
er.java:66)
at de.lmu.ifi.dbs.jfeaturelib.features.Sift.run(Sift.java:114)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor$ExtractionTask.run(Extract
or.java:633)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
0 WARN [pool-1-thread-4] de.lmu.ifi.dbs.jfeaturelib.features.Sift - Sift
Binary not executable: sift.exe
java.io.IOException: Sift Binary not executable: sift.exe
at de.lmu.ifi.dbs.jfeaturelib.features.sift.SiftWrapper.(SiftWrapp
er.java:66)
at de.lmu.ifi.dbs.jfeaturelib.features.Sift.run(Sift.java:114)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor$ExtractionTask.run(Extract
or.java:633)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
0 WARN [pool-1-thread-1] de.lmu.ifi.dbs.jfeaturelib.features.Sift - Sift
Binary not executable: sift.exe
java.io.IOException: Sift Binary not executable: sift.exe
at de.lmu.ifi.dbs.jfeaturelib.features.sift.SiftWrapper.(SiftWrapp
er.java:66)
at de.lmu.ifi.dbs.jfeaturelib.features.Sift.run(Sift.java:114)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor$ExtractionTask.run(Extract
or.java:633)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
16 ERROR [pool-1-thread-2] de.lmu.ifi.dbs.jfeaturelib.utils.Extractor - In
dex: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor.writeOutput(Extractor.java
:506)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor.access$400(Extractor.java:
77)
at de.lmu.ifi.dbs.jfeaturelib.utils.Extractor$ExtractionTask.run(Extract
or.java:643)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:51
1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:617)
at java.lang.Thread.run(Thread.java:745)
Please help on this
CUrrently the shape descriptors accept several kinds of images yet they really work only on binary images.
It should be checked if the application should be restricted to a ByteProcessor or BinaryProcessor
ich wollte gerade SIFT-Features mit JFeatureLib extrahieren. Dabei hat sich jedes mal ein save-File-Dialog geöffnet. Bei mir lag das Problem daran, dass in SiftWrapper.java, Zeile 82: new FileSaver(iPlus).saveAsPgm(); ersetzt werden musste durch: new FileSaver(iPlus).saveAsPgm(tmpFile.getAbsolutePath());
I
This issue was created by revision r230.
The detector should be refactored to work on graylevel images as it converts color images to grays in the code anyways
The licence is safe, so wrap the code
While going over the code of Haralick.java, I realized that the meanGrayValue attribute in the Coocurrence class is calculated as
meanGrayValue = Arrays2.sum(grayValue);
not sure if I'm missing something, but shouldn't it be
meanGrayValue = Arrays2.sum(grayValue) / (double) grayValue.length;
It has been reported that some shapre descriptors define the background as 0 some as -1.
This should be unified to 0.
I am using JFeatureLib library which I include in my project through Maven. However, my maven build is breaking because Maven cannot download two of the dependencies needed by JFeatureLib: imageanalysis and lire. Can you please fix this so that Maven can automatically download libraries needed by JFeatureLib to function properly.
Here is the link to Maven repo: http://mvnrepository.com/artifact/de.lmu.ifi.dbs.jfeaturelib/JFeatureLib/1.6.0
Thanks,
Kshitij Judah
This issue was created by revision r308.
beautify/test cleanup Method Kernel.process()
Different feature descriptors are parameterized differently.
It would be nice to have a full Java based API for settings parameters.
Some examples:
PHOG has Setters for bins and recursions, but not for canny.
setGradientSource seems to be a bit odd. There is an initial value, but after the first run() it becomes null, making the feature descriptor somewhat non-reentrant.
AutoColorCorrelogram on the other hand apparently cannot be configured at all from Java, but only via properties, meaning you can't use different parameterizations in the same run if you want to compare them.
I'm trying to extract Surf features without success. It seems it's missing a log4j dependency.
The code that I'm using:
import de.lmu.ifi.dbs.jfeaturelib.features.SURF
import ij.process.ColorProcessor;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import javax.imageio.ImageIO;
/**
* Example of extracting SURF features from section "Detecting the scale-invariant SURF features" in chapter 8.
*/
object Surf extends App {
// Read input image
val f = new File("test.jpg");
val image = new ColorProcessor(ImageIO.read(f));
val descriptor = new SURF();
descriptor.run(image);
val features = descriptor.getFeatures();
println(features);
}
build.sbt
name := "opencv2-scala-test"
organization := "samos"
exportJars := true
// Some dependencies like `javacpp` are packaged with maven-plugin packaging
classpathTypes += "maven-plugin"
libraryDependencies ++= Seq(
// "de.lmu.ifi.dbs.jfeaturelib" % "JFeatureLib" % "1.6.3",
"gov.nih.imagej" % "imagej" % "1.47"
)
libraryDependencies += "org.apache.logging.log4j" % "log4j-core" % "2.5"
libraryDependencies += "org.apache.logging.log4j" % "log4j-api" % "2.5"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.13"
Error that's seen:
java -jar opencv2-scala-test-assembly-0.1-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
at de.lmu.ifi.dbs.jfeaturelib.features.surf.IJFacade.(IJFacade.java:41)
at de.lmu.ifi.dbs.jfeaturelib.features.SURF.run(SURF.java:97)
at Surf$delayedInit$body.apply(Surf.scala:20)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at Surf$.main(Surf.scala:14)
at Surf.main(Surf.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 12 more
I cannot build my project that uses JFeatureLib due to following error:
[WARNING] Rule 6: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: de.lmu.ifi.dbs.utilities:common-extension-lib:jar:2.4.0
Found Banned Dependency: de.lmu.ifi.dbs.jfeaturelib:JFeatureLib:jar:1.6.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-rules) on project :
Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.
I tried to use mvn install -Denforcer.skip=true but it did not work as well (Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin).I tried to use mvn install -Denforcer.skip=true but it did not work as well (Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin).
I want to extract SIFT values
I have
JFeatureLib-1.6.4-jar-with-dependencies.jar
Downloaded the sift binary
have book.pgm
kept the jar and sift binary in C:\Program Files\Java\jdk1.8.0_25\bin
and kept book.pgm as in source folder
Also edited the properties of jar and set path to C:/Program Files/Java/jdk1.8.0_25/bin/sift.exe
I have also checked the permissions
I am running following command
C:\Program Files\Java\jdk1.8.0_25\bin>java -jar JFeatureLib-1.6.4-jar-with-dependencies.jar -D Sift -d D:\images\ -o D:\output.csv
I am not getting any error but output.csv is empty.. does not show any output.
Please help on this.
Am I missing something?
Waiting for your response...
This issue was created by revision r236.
This is a minor performance issue.
By using a 3x3 kernel, imageJ's methods can be used directly.
Can be replaced with a more efficient implementation
The master branch can't be compiled successfully. The error is cause by
waitFor()
method accept no parameters instead of two.This may not be a bug in jFeatureLib but filing it here as others may hit the same issue.
sbt downloads a different jar from maven when specifying jFeatureLib as dependency. The downloaded jar by sbt is missing classes.
build.sbt
name := "opencv2-scala-test"
organization := "samos"
libraryDependencies ++= Seq(
"de.lmu.ifi.dbs.jfeaturelib" % "JFeatureLib" % "1.6.3",
"gov.nih.imagej" % "imagej" % "1.46"
)
md5sum difference between maven downloaded and ivy2(sbt):
md5sum ~/.m2/repository/de/lmu/ifi/dbs/jfeaturelib/JFeatureLib/1.6.3/JFeatureLib-1.6.3.jar
0fcdab2cd25e21daedd2bf622a81941b
/home/samos/.m2/repository/de/lmu/ifi/dbs/jfeaturelib/JFeatureLib/1.6.3/JFeatureLib-1.6.3.jar
md5sum ~/.ivy2/cache/de.lmu.ifi.dbs.jfeaturelib/JFeatureLib/jars/JFeatureLib-1.6.3.jar
374d04f56dbdfea30ec6ca1661df47d7 /home/samos/.ivy2/cache/de.lmu.ifi.dbs.jfeaturelib/JFeatureLib/jars/JFeatureLib-1.6.3.jar
Example when running SBT compile
sbt compile
[info] Loading project definition from /home/samos/workspace/scala-opencv-test/project
[info] Set current project to opencv2-scala-test (in build file:/home/samos/workspace/scala-opencv-test/)
[info] Updating {file:/home/samos/workspace/scala-opencv-test/}scala-opencv-test...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading https://jcenter.bintray.com/de/lmu/ifi/dbs/jfeaturelib/JFeatureLib/1.6.3/JFeatureLib-1.6.3.jar ...
[info] [SUCCESSFUL ] de.lmu.ifi.dbs.jfeaturelib#JFeatureLib;1.6.3!JFeatureLib.jar (2143ms)
[info] downloading https://jcenter.bintray.com/de/lmu/ifi/dbs/utilities/common-extension-lib/2.4.0/common-extension-lib-2.4.0.jar ...
[info] [SUCCESSFUL ] de.lmu.ifi.dbs.utilities#common-extension-lib;2.4.0!common-extension-lib.jar (3466ms)
[info] Done updating.
[info] Compiling 1 Scala source to /home/samos/workspace/scala-opencv-test/target/scala-2.10/classes...
[error] /home/samos/workspace/scala-opencv-test/src/main/scala/Surf.scala:2: object SURF is not a member of package de.lmu.ifi.dbs.jfeaturelib.features
[error] import de.lmu.ifi.dbs.jfeaturelib.features.SURF
[error] ^
[error] /home/samos/workspace/scala-opencv-test/src/main/scala/Surf.scala:19: not found: type SURF
[error] val descriptor = new SURF();
[error] ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 16 s, completed Jan 14, 2016 3:31:41 PM
Surface Roughness Features
http://www.gcsca.net/IJ/SurfCharJ.html provides an ImageJ Plugin.
de.lmu.dbs.features.haralick.RoughnessCalculator might be an implementation. Possibly a wrapper around the plugin is more appropriate.
Scientific publication:
Chinga, G., Gregersen, O., Dougherty, B.,
"Paper surface characterisation by laser profilometry and image analysis",
Journal of Microscopy and Analysis, July 2003.
The third one, Correlation, of Haralick features shouldn't higher than 1, but in the result of your code. It will be unreasonably high. I'm trying to debug, any idea about it?
If I try to build the demo project I get the following error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building JFeatureLib-Demos 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for net.semanticmetadata:lire:jar:0.9.4-fg-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.305 s
[INFO] Finished at: 2017-11-16T12:01:49+01:00
[INFO] Final Memory: 8M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Demos: Could not resolve dependencies for project de.lmu.ifi.dbs.jfeaturelib:Demos:jar:1.0-SNAPSHOT: Failure to find net.semanticmetadata:lire:jar:0.9.4-fg-SNAPSHOT in http://maven.imagej.net/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of imagej.public has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Where can I get the missing dependency?
Hi,
thank you for this nice library which saved me a lot of time.
However, it would be nice if one could set ROIs for processing an image. At the moment I crop the image to the Roi and then apply the selected feature. However, it would be faster just to use the Roi during calculation.
Best,
Thorsten
The Extractor class currently only supports FeatureDescriptor s that live in the
de.lmu.ifi.dbs.jfeaturelib.features
package (or below).
It should support third-party packages, too, as long as they implement the desired interface.
It should also support the output file name "-" to output to stdout. There is a spelling error in the java source:
"cretae the output"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.