File: vtkImageQuantizeRGBToIndex.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,992 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 185; javascript: 165; objc: 153; tcl: 59
file content (116 lines) | stat: -rw-r--r-- 3,828 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkImageQuantizeRGBToIndex
 * @brief   generalized histograms up to 4 dimensions
 *
 * vtkImageQuantizeRGBToIndex takes a 3 component RGB image as
 * input and produces a one component index image as output, along with
 * a lookup table that contains the color definitions for the index values.
 * This filter works on the entire input extent - it does not perform
 * streaming, and it does not supported threaded execution (because it has
 * to process the entire image).
 *
 * To use this filter, you typically set the number of colors
 * (between 2 and 65536), execute it, and then retrieve the lookup table.
 * The colors can then be using the lookup table and the image index.
 *
 * This filter can run faster, by initially sampling the colors at a
 * coarser level. This can be specified by the SamplingRate parameter.
 *
 * The "index-image" viewed as a greyscale image, is usually quite
 * arbitrary, accentuating contrast where none can be perceived in
 * the original color image.
 * To make the index image more meaningful (e.g. for image segmentation
 * operating on scalar images), we sort the mean colors by luminance
 * and re-map the indices accordingly. This option does not introduce any
 * computational complexity and has no impact on actual colors in the
 * lookup table (only their order).
 */

#ifndef vtkImageQuantizeRGBToIndex_h
#define vtkImageQuantizeRGBToIndex_h

#include "vtkImageAlgorithm.h"
#include "vtkImagingColorModule.h" // For export macro

VTK_ABI_NAMESPACE_BEGIN
class vtkLookupTable;

class VTKIMAGINGCOLOR_EXPORT vtkImageQuantizeRGBToIndex : public vtkImageAlgorithm
{
public:
  static vtkImageQuantizeRGBToIndex* New();
  vtkTypeMacro(vtkImageQuantizeRGBToIndex, vtkImageAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  ///@{
  /**
   * Set / Get the number of color index values to produce - must be
   * a number between 2 and 65536.
   */
  vtkSetClampMacro(NumberOfColors, int, 2, 65536);
  vtkGetMacro(NumberOfColors, int);
  ///@}

  vtkSetVector3Macro(SamplingRate, int);
  vtkGetVector3Macro(SamplingRate, int);

  vtkSetMacro(SortIndexByLuminance, bool);
  vtkGetMacro(SortIndexByLuminance, bool);
  vtkBooleanMacro(SortIndexByLuminance, bool);

  ///@{
  /**
   * Get the resulting lookup table that contains the color definitions
   * corresponding to the index values in the output image.
   */
  vtkGetObjectMacro(LookupTable, vtkLookupTable);
  ///@}

  vtkGetMacro(InitializeExecuteTime, double);
  vtkGetMacro(BuildTreeExecuteTime, double);
  vtkGetMacro(LookupIndexExecuteTime, double);

  ///@{
  /**
   * For internal use only - get the type of the image
   */
  vtkGetMacro(InputType, int);
  ///@}

  ///@{
  /**
   * For internal use only - set the times for execution
   */
  vtkSetMacro(InitializeExecuteTime, double);
  vtkSetMacro(BuildTreeExecuteTime, double);
  vtkSetMacro(LookupIndexExecuteTime, double);
  ///@}

protected:
  vtkImageQuantizeRGBToIndex();
  ~vtkImageQuantizeRGBToIndex() override;

  vtkLookupTable* LookupTable;
  int NumberOfColors;
  int InputType;
  int SamplingRate[3];
  bool SortIndexByLuminance;

  double InitializeExecuteTime;
  double BuildTreeExecuteTime;
  double LookupIndexExecuteTime;

  int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
  int RequestUpdateExtent(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

private:
  vtkImageQuantizeRGBToIndex(const vtkImageQuantizeRGBToIndex&) = delete;
  void operator=(const vtkImageQuantizeRGBToIndex&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif