annotate OrthancStone/Sources/Toolbox/ImageToolbox.h @ 1743:12528a80e3dd

fix build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Feb 2021 09:15:31 +0100
parents 9ac2a65d4172
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
15 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1596
diff changeset
19 * <http://www.gnu.org/licenses/>.
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20 **/
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #pragma once
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 #include "../StoneEnumerations.h"
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 #include "LinearAlgebra.h"
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1291
diff changeset
28 #include <Images/ImageAccessor.h>
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 namespace OrthancStone
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 {
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 This structure represents the result of an histogram computation
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 bins[0] contains the values in [minValue , minValue + binSize [
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 bins[1] contains the values in [minValue + binSize, minValue + 2*binSize [
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 bins[2] contains the values in [minValue + 2*binSize, minValue + 3*binSize [
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 ...
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 bins[N-1] contains the values in [minValue + (N-1)*binSize, minValue + N*binSize [
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 struct HistogramData
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 {
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 std::vector<size_t> bins;
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 double minValue;
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 double binSize;
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 };
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 Dumps the supplied histogram to the supplied strings
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 void DumpHistogramResult(std::string& s, const HistogramData& hd);
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 This will compute the histogram of the supplied image (count the number of
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 pixels).
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 The image must contain arithmetic pixels (that is, having a single component,
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 integer or float). Compound pixel types like RGB, YUV are not supported and
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 will cause this function to throw an exception.
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 The range of available values will be split in sets of size `binSize`, and
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 each set will contain the number of pixels in the given bin
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 (see HistogramResult above).
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 void ComputeHistogram(const Orthanc::ImageAccessor& img,
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 HistogramData& hd, double binSize);
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 Computes the min max values in an image
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 void ComputeMinMax(const Orthanc::ImageAccessor& img,
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 double& minValue, double& maxValue);
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76
1484
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
77
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
78 class ImageToolbox
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
79 {
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
80 public:
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
81 static bool IsDecodingSupported(Orthanc::DicomTransferSyntax& transferSyntax);
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
82 };
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 }