annotate OrthancStone/Sources/Toolbox/ImageToolbox.h @ 1893:90b5e116a5f9

removed DicomStructureSet::GetStructureColor()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 19 Jan 2022 14:01:57 +0100
parents 7053b8a0aaec
children 07964689cb0b
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
1871
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
7053b8a0aaec upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1870
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * the License, or (at your option) any later version.
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 *
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * Lesser General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
1286
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
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #pragma once
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 #include "../StoneEnumerations.h"
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include "LinearAlgebra.h"
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1291
diff changeset
29 #include <Images/ImageAccessor.h>
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 namespace OrthancStone
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 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35 This structure represents the result of an histogram computation
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 bins[0] contains the values in [minValue , minValue + binSize [
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 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
39 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
40 ...
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 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
42
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 struct HistogramData
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 {
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 std::vector<size_t> bins;
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 double minValue;
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 double binSize;
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 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 Dumps the supplied histogram to the supplied strings
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 void DumpHistogramResult(std::string& s, const HistogramData& hd);
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 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 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
58 pixels).
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 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
61 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
62 will cause this function to throw an exception.
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 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
65 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
66 (see HistogramResult above).
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 void ComputeHistogram(const Orthanc::ImageAccessor& img,
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 HistogramData& hd, double binSize);
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 /**
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 Computes the min max values in an image
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 */
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 void ComputeMinMax(const Orthanc::ImageAccessor& img,
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 double& minValue, double& maxValue);
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77
1484
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
78
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
79 class ImageToolbox
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
80 {
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
81 public:
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
82 static bool IsDecodingSupported(Orthanc::DicomTransferSyntax& transferSyntax);
121d01aa328e SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1455
diff changeset
83 };
1286
ddb6676bbcbf Added Histogram functions (new files: ImageToolbox...)
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 }