Skip to content

Package: HistogramExample

HistogramExample

nameinstructionbranchcomplexitylinemethod
HistogramExample()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
main(String[])
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
process()
M: 73 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.mistral.example.histogram;
28:
29: import java.io.IOException;
30: import java.nio.file.Path;
31: import it.tidalwave.image.EditableImage;
32: import it.tidalwave.image.op.CropOp;
33: import it.tidalwave.image.op.HistogramOp;
34: import it.tidalwave.image.op.ReadOp;
35: import lombok.extern.slf4j.Slf4j;
36:
37: /***********************************************************************************************************************
38: *
39: * @author Fabrizio Giudici
40: *
41: **********************************************************************************************************************/
42: @Slf4j
43: public class HistogramExample
44: {
45: public static void main (final String[] args)
46: throws IOException
47: {
48: final var e = new HistogramExample();
49: e.process();
50: }
51:
52: public void process()
53: throws IOException
54: {
55: //
56: // Loads the image
57: //
58: final var file = Path.of("../images/20030701-0043.NEF");
59: final var image = EditableImage.create(new ReadOp(file));
60: log.info("Image loaded in " + image.getLatestOperationDuration() + " msec");
61: //
62: // Crops the image
63: //
64: image.executeInPlace(new CropOp(10, 10, 600, 400));
65: log.info("Image cropped in " + image.getLatestOperationDuration() + " msec");
66: //
67: // Computes the histogram
68: //
69: final var histogram = image.executeInPlace(new HistogramOp()).getHistogram();
70: log.info("Histogram computed in " + image.getLatestOperationDuration() + " msec");
71: //
72: // Prints some information item from the histogram
73: //
74:• for (var band = 0; band < histogram.getBandCount(); band++)
75: {
76: final var min = histogram.getMin(band);
77: final var max = histogram.getMax(band);
78: final var frequencies = histogram.getFrequencies(band);
79: log.info("band #" + band + ": min=" + min + " max=" + max + " " + frequencies.length + " samples");
80: }
81: }
82: }