color_map.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import numpy as np
  15. def get_colormap(rgb=False):
  16. """
  17. Get colormap
  18. """
  19. color_list = np.array(
  20. [
  21. 0xFF,
  22. 0x00,
  23. 0x00,
  24. 0xCC,
  25. 0xFF,
  26. 0x00,
  27. 0x00,
  28. 0xFF,
  29. 0x66,
  30. 0x00,
  31. 0x66,
  32. 0xFF,
  33. 0xCC,
  34. 0x00,
  35. 0xFF,
  36. 0xFF,
  37. 0x4D,
  38. 0x00,
  39. 0x80,
  40. 0xFF,
  41. 0x00,
  42. 0x00,
  43. 0xFF,
  44. 0xB2,
  45. 0x00,
  46. 0x1A,
  47. 0xFF,
  48. 0xFF,
  49. 0x00,
  50. 0xE5,
  51. 0xFF,
  52. 0x99,
  53. 0x00,
  54. 0x33,
  55. 0xFF,
  56. 0x00,
  57. 0x00,
  58. 0xFF,
  59. 0xFF,
  60. 0x33,
  61. 0x00,
  62. 0xFF,
  63. 0xFF,
  64. 0x00,
  65. 0x99,
  66. 0xFF,
  67. 0xE5,
  68. 0x00,
  69. 0x00,
  70. 0xFF,
  71. 0x1A,
  72. 0x00,
  73. 0xB2,
  74. 0xFF,
  75. 0x80,
  76. 0x00,
  77. 0xFF,
  78. 0xFF,
  79. 0x00,
  80. 0x4D,
  81. ]
  82. ).astype(np.float32)
  83. color_list = color_list.reshape((-1, 3))
  84. if not rgb:
  85. color_list = color_list[:, ::-1]
  86. return color_list.astype("int32")