Skip to content

Commit

Permalink
#45: codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
romankh3 committed Apr 8, 2019
1 parent 19a30cf commit db95ae6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
The program in Java that compares any 2 images and shows the differences visually by drawing rectangles.

## Requirements
* Implementation is using only standard core language and platform features, no 3rd party libraries and plagiarized code is permitted.
* Pixels (with the same coordinates in two images) can be visually similar, but have different values of RGB. 2 pixels are considered to be "different" if they differ more than 10% from each other.
* The output of the comparison is a copy of one of the images The differences are outlined with red rectangles as shown below.
* No third party libraries or borrowed code are in usage.
* Implementation is using only standard core language and platform features, no 3rd party libraries and plagiarized code is permitted.
* Pixels (with the same coordinates in two images) can be visually similar, but have different values of RGB. 2 pixels are considered to be "different" if they differ more than 10% from each other.
* The output of the comparison is a copy of one of the images The differences are outlined with red rectangles as shown below.
* No third party libraries or borrowed code are in usage.

## Building

To clone and build this project, run the following commands:

```
```bash
$ git clone https://github.com/romankh3/image-comparison
$ cd image-comparison
$ ./gradlew check jar
Expand All @@ -30,25 +30,25 @@ Run the `./run.sh` script to run the demo.
You will get the result of comparing two images.
The images, which are using:

**Image 1**
##### Image 1

![image1](https://user-images.githubusercontent.com/16310793/28955567-52edeabe-78f0-11e7-8bb2-d435c8df23ff.png)

**Image 2**
##### Image 2

![image2](https://user-images.githubusercontent.com/16310793/28955566-52ead892-78f0-11e7-993c-847350da0bf8.png)

**Result**
##### Result

![result](https://user-images.githubusercontent.com/16310793/28955568-52f23e02-78f0-11e7-92c5-07602b6a0887.png)

Also you can get them from:

```
```bash
${projectDir}/src/main/resources/image1.png
${projectDir}/src/main/resources/image2.png
```
```
```bash
${projectDir}/build/result.png
```

Expand All @@ -60,19 +60,19 @@ After building with `./gradlew jar`, you will find the runnable jar at `${projec

To compare two images in files `a.png` and `b.png`, for example, run:

```
```bash
java -jar image-comparison.jar a.png b.png
```

To save the result image in a third file, say `comparison.png`, just give that file as a third argument:

```
```bash
java -jar image-comparison.jar a.png b.png comparison.png
```

To show more usage details, run:

```
```bash
java -jar image-comparison.jar -h
```

Expand All @@ -99,9 +99,9 @@ class Example {
## License
This project is unlicense - see the [LICENSE](LICENSE) file for details

### Thanks [@dee-y](https://github.com/dee-y) for designing this logo
#### Thanks [@dee-y](https://github.com/dee-y) for designing this logo

### Also if you're interesting - see my other repositories
* [Raspberry home ecosystem](https://github.com/romankh3/raspberrypi-home-ecosystem) - home ecosystem based on raspberry pi.
* [Movie Tracking](https://github.com/romankh3/movietracking) Simple API for tracking movies with favorite actors for the specific time.
* [Tic Tac Toe NxM](https://github.com/romankh3/tictactoe)- Own implementation. For any rectangle and any winner line count.
* [Raspberry home ecosystem](https://github.com/romankh3/raspberrypi-home-ecosystem) - home ecosystem based on raspberry pi.
* [Movie Tracking](https://github.com/romankh3/movietracking) Simple API for tracking movies with favorite actors for the specific time.
* [Tic Tac Toe NxM](https://github.com/romankh3/tictactoe)- Own implementation. For any rectangle and any winner line count.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 2.0.1 RELEASE NOTES
# 2.0.1
- fixed bug #21

# 2.0.0 RELEASE NOTES
# 2.0.0
- use as a library
- added RELEASE_NOTES.md file.
8 changes: 4 additions & 4 deletions src/main/java/ua/comparison/image/CommandLineUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
*/
public class CommandLineUtil {

static ImageComparison create(String... args) throws IOException, URISyntaxException {
public static ImageComparison create(String... args) throws IOException, URISyntaxException {
Optional<Arguments> arguments = new ArgsParser().parseArgs(args);
return arguments.isPresent() ? create(arguments.get()) : createDefault();
}

static ImageComparison createDefault() throws IOException, URISyntaxException {
public static ImageComparison createDefault() throws IOException, URISyntaxException {
return new ImageComparison(
readImageFromResources("image1.png"),
readImageFromResources("image2.png"),
null);
}

static ImageComparison create(ArgsParser.Arguments args) throws IOException {
public static ImageComparison create(ArgsParser.Arguments args) throws IOException {
return new ImageComparison(
readImageFromFile(args.getImage1()),
readImageFromFile(args.getImage2()),
args.getDestinationImage().orElse(null));
}

static void handleResult(ImageComparison instance, IOConsumer<File> saveToFile, Runnable showUI)
public static void handleResult(ImageComparison instance, IOConsumer<File> saveToFile, Runnable showUI)
throws IOException {
if (instance.getDestination().isPresent()) {
saveToFile.accept(instance.getDestination().get());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ua/comparison/image/ImageComparison.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void joinToRegion(int row, int col) {
}
}

Optional<File> getDestination() {
public Optional<File> getDestination() {
return Optional.ofNullable(destination);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Test;


/**
* Unit-level testing for {@link ImageComparison} object.
*/
Expand Down Expand Up @@ -52,8 +50,8 @@ public void testMainClass() throws IOException, URISyntaxException {
ImageComparison.main(args);

//then
Assert.assertNotNull(image1);
Assert.assertNotNull(image2);
assertNotNull(image1);
assertNotNull(image2);
}

/**
Expand Down

0 comments on commit db95ae6

Please sign in to comment.