Giter VIP home page Giter VIP logo

imaging's Introduction

imaging

Imaging

DOI License: MPL 2.0 GitHub release javadoc Maven Central

The imaging framework provides different functionality in the context of image processing and computer vision. For this there are many image processing related implementations in the project but also connection classes to other frameworks (e.g. OpenCV) to extend its functionality. Get a detailed overview on our maven site.

Getting Started

The project is structured into multiple submodules. API builds the base module which contains the domain classes as well as the interfaces. The core module builds the base implementation with pure java functionality. In addition to these two modules there are modules for connecting to other frameworks for imagej, nd4j, opencv, openimaj, pdfbox, tesseract and microsoft-cognitive-services. These modules are wrappers for functionality that is provided in either of these libraries.

To use the Imaging project you simply need to add the required dependencies like:

<dependency>
    <groupId>science.aist.imaging</groupId>
    <artifactId>api</artifactId> <!-- alternatives core, nd4j, openimaj, imagej, opencv, pdfbox, tesseract, microsoft-cognitive-services -->
    <version>${imaging.version}</version> <!-- e.g. 1.0.0 -->
</dependency>

Examples

A simple example using the Core module (1) creates an image using the ImageFactoryFactory and (2) draws a circle at a given position.

// (1) Create a new image
ImageWrapper<short[][][]> image = ImageFactoryFactory.getImageFactory(short[][][].class).getImage(100, 100, ChannelType.Greyscale);

// (2) Draw on the image
DrawCircle<short[][][]> draw = new DrawCircle<>();
draw.setColor(new double[]{1});
draw.accept(image, new JavaPoint2D(5, 5));

A more advanced example is shown in the following code snippet, that shows the module interoperability of the Imaging project based on the GenericImageFunction. Note: GenericImageFunction casts its input image, and the result of the wrapped function if necessary, which affects its resource requirements.

// (1) Load OpenCV DLLs
AistCVLoader.loadShared();

// (2) Create a random input image for the test
Random rand = new Random(768457);
ImageWrapper<double[][][]> input = ImageFactoryFactory.getImageFactory(double[][][].class).getRandomImage(10, 10, ChannelType.RGB, rand, 0, 255, true);

// (3) Prepare the function to be applied (Note: it is implemented for OpenCV only!)
OpenCVThresholdFunction thresholdFunction = new OpenCVThresholdFunction();
GenericImageFunction<double[][][], double[][][], Mat, Mat> function = new GenericImageFunction<>(thresholdFunction, Mat.class, double[][][].class);

// (4) Apply the function (Note: on a non-OpenCV image)
ImageWrapper<double[][][]> thresholdResult = function.apply(input);

FAQ

If you have any questions, please checkout our FAQ section.

Contributing

First make sure to read our general contribution guidelines.

Licence

Copyright (c) 2020 the original author or authors. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

The following code is under different licence and copyright:

Licence Filepaths
MIT
see LICENSE_MIT_JDIEMKE
api/src/main/java/science/aist/imaging/api/domain/twodimensional/JavaTriangle2D
MIT
see LICENSE_MIT_KIERS
core/src/test/java/science/aist/imaging/service/core/pointprocessing/GrahamConvexHull
Apache
see LICENSE_APACHE
tesseract/tessdata/*

Research

If you are going to use this project as part of a research paper, we would ask you to reference this project by citing it.

DOI

Additionally, this work was used in the following publications:

imaging's People

Contributors

cpraschl avatar pointan avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

imaging's Issues

GenericImageFunction

Is your feature request related to a problem? Please describe.
The idea of the Imaging project is to create a framework overarching image processing pipeline and to connect different Java libraries. Currently, it is required to manually convert ImageWrapper's to the required type of a specifc implementation (especially if you use it over module borders). So add a functionality to overcome those borders.

Describe the solution you'd like
Add a generic image function implementation that wraps any given ImageFunction and converts the actual input to the wrapped function's input (if necessary). In addition to that the wrapped function's result is in turn converted to an expected output (if necessary).

The code could look something like (not tested!):

public class GenericImageFunction<I, O> implements ImageFunction<?, O> {

   public GenericImageFunction(ImageFunction<I, ?> function, Class<I> functionInputType, Class<O> outputType){
     this(function, ImageFactoryFactory.getImageFactory(functionInputType), ImageFactoryFactory.getImageFactory(outputType));
   }

   public GenericImageFunction(ImageFunction<I, ?> function, ImageFactory<I> functionInputFactory, ImageFactory<O> outputFactory) {
    ... // initialize variables
  }

   public ImageWrapper<O> apply(ImageWrapper<?> image) {
       ImageWrapper<I> input;
       if(image.getSupportedType().equals(functionInputFactory.getSupportedType())){
           input = (ImageWrapper<I>) image;
       } else {
           input = image.createCopy(functionInputFactory);
       }

      ImageWrapper<?> functionResult = function.apply(input);
      
      if(functionResult.getSupportedType().equals(outputFactory.getSupportedType())){
           return (ImageWrapper<O>) functionResult;
       } else {
           ImageWrapper<O> result = functionResult.createCopy(outputFactory);
           functionResult.close();  // close interim result
           return result;
       }
   }
}

Requires a getSupportedType Function in ImageWrapper (compare to ImageFactory)

public interface ImageWrapper<I> {
   ...
   Class<I> getSupportedType();
}

[BUG] GenericImageConsumer.accept() does not close copy

Describe the bug
The GenericImageConsumer currently does not close the temporarily created copy in accept.

To Reproduce
Have a look at https://github.com/FHOOEAIST/imaging/blob/main/api/src/main/java/science/aist/imaging/api/GenericImageConsumer.java#L50

Expected behavior
Close temporarily created copy.
Change to:

    @Override
    public void accept(ImageWrapper<I> iImageWrapper, T t) {
        if(iImageWrapper.getSupportedType().equals(consumerFactory.getSupportedType())){
            consumer.accept(CastUtils.cast(iImageWrapper), t);
        } else {
            ImageWrapper<I2> copy = iImageWrapper.createCopy(consumerFactory);
            try {
              consumer.accept(copy, t);
              copy.copyTo(iImageWrapper);
            } finally {
               copy.close();
            }
        }
    }

ImageWrapper createCopy - Comfort overload

Add a comfort overload for createCopy() to the ImageWrapper interface

default <X> ImageWrapper<X> createCopy(Class<X> targetClass) {
        return createCopy(ImageFactoryFactory.getImageFactory(targetClass);
}

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

maven
api/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
core/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
imagej/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
javacv/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api 2.0.1-SNAPSHOT
mesh/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
microsoftcognitiveservices/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
  • science.aist.imaging:core ${project.parent.version}
nd4j/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
opencv/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
  • science.aist.imaging:core ${project.parent.version}
openimaj/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
openjfx/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • science.aist.imaging:api ${project.parent.version}
  • org.openjfx:javafx-media 11
pdfbox/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
pom.xml
  • net.imagej:ij 1.53g
  • org.bytedeco:javacv 1.5.6
  • org.bytedeco:javacv-platform 1.5.6
  • org.orbisgis:jdelaunay 0.5.3
  • org.springframework:spring-beans 4.3.7.RELEASE
  • org.springframework:spring-core 4.3.7.RELEASE
  • org.springframework:spring-context 4.3.7.RELEASE
  • org.springframework:spring-web 4.3.7.RELEASE
  • org.springframework:spring-webmvc 4.3.7.RELEASE
  • com.fasterxml.jackson.core:jackson-core 2.7.9
  • com.fasterxml.jackson.core:jackson-databind 2.7.9
  • com.fasterxml.jackson.core:jackson-annotations 2.7.9
  • org.nd4j:nd4j-api 1.0.0-beta7
  • org.nd4j:nd4j-native 1.0.0-beta7
  • science.aist:aistcv 4.5.3
  • com.drewnoakes:metadata-extractor 2.13.0
  • org.openimaj:core-image 1.3.10
  • org.apache.pdfbox:pdfbox 2.0.14
  • org.apache.maven.plugins:maven-project-info-reports-plugin 3.0.0
  • org.apache.maven.plugins:maven-javadoc-plugin 3.1.1
  • javax.activation:activation 1.1.1
  • javax.xml.bind:jaxb-api 2.3.0
  • com.sun.xml.bind:jaxb-core 2.3.0
  • com.sun.xml.bind:jaxb-impl 2.3.0
  • org.projectlombok:lombok 1.18.10
  • org.springframework:spring-beans 4.3.7.RELEASE
  • org.springframework:spring-core 4.3.7.RELEASE
  • org.springframework:spring-test 4.3.7.RELEASE
  • org.springframework:spring-context 4.3.7.RELEASE
  • org.testng:testng 6.11
  • science.aist.seshat:api 1.1.0
  • science.aist:jack 2.3.1
  • org.hamcrest:hamcrest-all 1.3
  • org.mockito:mockito-core 3.11.1
  • org.apache.maven.plugins:maven-scm-publish-plugin 3.0.0
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.6.8
  • org.apache.maven.plugins:maven-javadoc-plugin 3.1.1
  • org.apache.maven.plugins:maven-site-plugin 3.8.2
  • org.apache.maven.wagon:wagon-webdav-jackrabbit 3.3.4
  • org.apache.maven.doxia:doxia-module-markdown 1.9
  • org.apache.maven.plugins:maven-surefire-plugin 2.18.1
  • org.apache.maven.plugins:maven-gpg-plugin 1.6
  • org.apache.maven.plugins:maven-release-plugin 2.5.3
  • org.jacoco:jacoco-maven-plugin 0.8.4
  • org.apache.maven.plugins:maven-dependency-plugin 3.1.1
  • org.apache.maven.plugins:maven-surefire-plugin 2.18.1
  • org.sonarsource.java:sonar-jacoco-listeners 5.14.0.18788
tesseract/pom.xml
  • science.aist.imaging:imaging 2.0.1-SNAPSHOT
  • org.bytedeco.javacpp-presets:tesseract-platform 3.04.01-1.3
  • science.aist.imaging:api ${project.parent.version}
  • science.aist.imaging:core ${project.parent.version}

  • Check this box to trigger a request for Renovate to run again on this repository

Fix Javadoc Generation

The project is built using java11+, which means that everything that is not within a module gets assign to the default module. This causes the javadoc-search to work incorrectly.

...
<configuration>
    ...
    <additionalJOptions>
        <additionalJOption>--no-module-directories</additionalJOption>
    </additionalJOptions>
   ...
</configuration>
...

Adapt the module packages

Is your feature request related to a problem? Please describe.
We should think of refactoring the packages in the additional modules and remove the additional "service" subpackage.

Describe the solution you'd like
Change packages like science.aist.imaging.service.mesh; to science.aist.imaging.mesh;.
Same for the other modules as core, imagej, mesh, microsoftcognitiveservices, nd4j, opencv, openimaj, pdfbox, tesseract, ...

Priority
Priority of this request Minor

Extend Readme - Multi Modul Example

Describe the solution you'd like
Extend the project readme by a multi modul example.
E.g. Loading an image with OpenCV, applying some OpenCV filter and further apply some API/OpenIMAJ/... filter.

Add comparison to python/numpy

Describe the solution you'd like

Add a section to the readme that compares the performance of Imaging to Python/numpy to show the advantages of image processing in Java.

Add possiblity to chain multiple ImageFunctions

Allow chaining multiple image functions:
e.g.

ImageFunction<..> x = ...;
ImageFunction<..> y = ...;
var z = x.andThen(y);

Make sure that the interim result that is produced from x and used as an input of y, needs to be closed.

Usage of Wrappers

Is your feature request related to a problem? Please describe.
Currently, we are using two architectural concepts in the imaging project:

  • Image processing: Interchangable Wrapper classes (e.g. ImageWrapper)
  • Geometry: Rich domain implementations (e.g. JavaPoint2D, JavaPolygon2D, ...)

Describe the solution you'd like
To have a more consistent architecture it would be great if we move the rich implementations of e.g. JavaPoint2D to the associated WrapperClasses.

Priority
Minor priority, would also need a new major version.

ChannelType Scale Function

Add a Scale Function to the ChannelType which allows to scale a given value from a source range to a target range, which is defined by the ChannelType's min and max values.

public double scale(double value, int channel, double currentMin, double currentMax) {
  ...
}

This function could be reused in the ImageWrapper implementations of e.g. OpenIMAJ or OpenJFX, where images are represented with a range from 0 to 1 instead of 0 to 255 as in other frameworks.

[BUG] Non-required dependencies

Describe the bug
There are multiple non-required maven dependencies left over from the open sourcing process.

To Reproduce
E.g. Look into API pom.xml

Expected behavior
Removed dependencies.

Add JavaFX support

Add support to JavaFX's Image class using the WritableImage class

    WritableImage wr =  new WritableImage(width, height);
    PixelWriter pw = wr.getPixelWriter();
    for (int x = 0; x < image.getWidth(); x++) {
       for (int y = 0; y < image.getHeight(); y++) {
          pw.setArgb(x, y, image.getRGB(x, y));
        }
    }

Can be converted to JavaFX's Image like:

new ImageView(wr).getImage();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.