summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasile Vilvoiu <vasi@vilvoiu.ro>2021-10-20 21:58:13 +0300
committerVasile Vilvoiu <vasi@vilvoiu.ro>2021-10-20 21:58:13 +0300
commita568a2bbf457283717440ecf8711e87db7a4201e (patch)
treecf491c9d08b7355d241b0e79a5f3de9a2dc80eb3
parentd445fd00976fa3ce7ce2eda4d18e9b489a78aa67 (diff)
Add 'hot' and 'inferno' colormaps.
Make 'inferno' default.
-rw-r--r--man/specgram.16
-rw-r--r--man/specgram.1.html7
-rw-r--r--man/specgram.1.pdfbin37617 -> 37623 bytes
-rw-r--r--resources/readme_images/colormaps.pngbin874694 -> 1130008 bytes
-rw-r--r--resources/readme_images/example.pngbin1035704 -> 1167681 bytes
-rw-r--r--resources/readme_images/example_file.pngbin837171 -> 1070031 bytes
-rw-r--r--resources/readme_images/example_live.pngbin697722 -> 896739 bytes
-rwxr-xr-xresources/readme_images/generate.sh10
-rw-r--r--src/color-map.cpp45
-rw-r--r--src/color-map.hpp24
-rw-r--r--src/configuration.cpp8
11 files changed, 87 insertions, 13 deletions
diff --git a/man/specgram.1 b/man/specgram.1
index 6e60aaa..0cbf166 100644
--- a/man/specgram.1
+++ b/man/specgram.1
@@ -1,4 +1,4 @@
-.TH SPECGRAM 1 "2021-07-16"
+.TH SPECGRAM 1 "2021-10-20"
.SH NAME
specgram \- create spectrograms from raw files or standard input
@@ -221,12 +221,12 @@ Integer inputs don't usually need prescaling, as they are normalized based on th
.TP
.BR \-c ", " \-\-colormap =\fICOLORMAP\fR
Color scheme.
-Valid values are: jet, gray, purple, blue, green, orange, red.
+Valid values are: jet, hot, inferno, gray, purple, blue, green, orange, red.
If \fICOLORMAP\fR is neither of these values, then it is interpreted either as a 6 character hex string (RGB color) or an 8 character hex string (RGBA color).
In this case, a gradient between the background color and the color specified by the hex string will be used as a color map.
-Default is jet.
+Default is inferno.
.TP
.BR \-\-bg-color =\fIBGCOLOR\fR
diff --git a/man/specgram.1.html b/man/specgram.1.html
index 6cc0a1c..367fa10 100644
--- a/man/specgram.1.html
+++ b/man/specgram.1.html
@@ -1,5 +1,5 @@
<!-- Creator : groff version 1.22.4 -->
-<!-- CreationDate: Fri Jul 16 11:40:40 2021 -->
+<!-- CreationDate: Wed Oct 20 18:28:19 2021 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -387,7 +387,8 @@ limits.</p>
<b>&minus;&minus;colormap</b>=<i>COLORMAP</i></p>
<p style="margin-left:22%;">Color scheme. Valid values are:
-jet, gray, purple, blue, green, orange, red.</p>
+jet, hot, inferno, gray, purple, blue, green, orange,
+red.</p>
<p style="margin-left:22%; margin-top: 1em">If
<i>COLORMAP</i> is neither of these values, then it is
@@ -397,7 +398,7 @@ gradient between the background color and the color
specified by the hex string will be used as a color map.</p>
<p style="margin-left:22%; margin-top: 1em">Default is
-jet.</p>
+inferno.</p>
<p style="margin-left:11%;"><b>&minus;&minus;bg-color</b>=<i>BGCOLOR</i></p>
diff --git a/man/specgram.1.pdf b/man/specgram.1.pdf
index f393414..d6a0be4 100644
--- a/man/specgram.1.pdf
+++ b/man/specgram.1.pdf
Binary files differ
diff --git a/resources/readme_images/colormaps.png b/resources/readme_images/colormaps.png
index f82cbc5..5f7ce25 100644
--- a/resources/readme_images/colormaps.png
+++ b/resources/readme_images/colormaps.png
Binary files differ
diff --git a/resources/readme_images/example.png b/resources/readme_images/example.png
index 63652bb..067d517 100644
--- a/resources/readme_images/example.png
+++ b/resources/readme_images/example.png
Binary files differ
diff --git a/resources/readme_images/example_file.png b/resources/readme_images/example_file.png
index 80b0bbd..0735988 100644
--- a/resources/readme_images/example_file.png
+++ b/resources/readme_images/example_file.png
Binary files differ
diff --git a/resources/readme_images/example_live.png b/resources/readme_images/example_live.png
index 6ef9ec9..eb4a5af 100644
--- a/resources/readme_images/example_live.png
+++ b/resources/readme_images/example_live.png
Binary files differ
diff --git a/resources/readme_images/generate.sh b/resources/readme_images/generate.sh
index 348f6af..3d82f34 100755
--- a/resources/readme_images/generate.sh
+++ b/resources/readme_images/generate.sh
@@ -1,5 +1,7 @@
#!/bin/sh
specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_jet.png -c jet
+specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_hot.png -c hot
+specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_inferno.png -c inferno
specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_gray.png -c gray
specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_purple.png -c purple
specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_dont_know_why colormap_blue.png -c blue
@@ -9,6 +11,8 @@ specgram -eqz --bg-color=00000000 --fg-color=000000ff -i ../clips/norah_jones_do
montage \
-label "jet" colormap_jet.png \
+-label "hot" colormap_hot.png \
+-label "inferno" colormap_inferno.png \
-label "gray" colormap_gray.png \
-label "purple" colormap_purple.png \
-label "blue" colormap_blue.png \
@@ -19,12 +23,12 @@ montage \
rm -rf colormap_*.png
-specgram -eq -f 8192 -y 4000 --bg-color=00000000 --fg-color=000000ff -i ../clips/rammstein_dalai_lama example_file.png
+specgram -eq -f 8192 -y 4000 --bg-color=00000000 --fg-color=000000ff -i ../clips/rammstein_dalai_lama example_file.png -s dBFS,-75,-25
# Following command should be used for screenshot acquisition
-# cat ../clips/rammstein_dalai_lama | specgram -eql -f 8192 -y 4000 -k 440
+# cat ../clips/rammstein_dalai_lama | specgram -eql -f 8192 -y 4000 -k 440 -s dBFS,-75,-25
montage \
-label "Live view" example_live.png \
-label "File output" example_file.png \
--geometry 400x example.png \ No newline at end of file
+-geometry 400x example.png
diff --git a/src/color-map.cpp b/src/color-map.cpp
index 7bf7e4e..3b51af1 100644
--- a/src/color-map.cpp
+++ b/src/color-map.cpp
@@ -20,6 +20,12 @@ ColorMap::Build(ColorMapType type, const sf::Color& bg_color, const sf::Color& c
case ColorMapType::kJet:
return std::make_unique<JetColorMap>();
+ case ColorMapType::kHot:
+ return std::make_unique<HotColorMap>();
+
+ case ColorMapType::kInferno:
+ return std::make_unique<InfernoColorMap>();
+
case ColorMapType::kGray:
return std::make_unique<TwoColorMap>(sf::Color::Black, sf::Color::White);
@@ -150,4 +156,41 @@ JetColorMap::JetColorMap() : InterpolationColorMap(
{ 0.0f, 1.0f / 9.0f, 23.0f / 63.0f, 13.0f / 21.0f, 47.0f / 63.0f, 55.0 / 63.0, 1.0f }
)
{
-} \ No newline at end of file
+}
+
+HotColorMap::HotColorMap() : InterpolationColorMap(
+ {
+ sf::Color(0, 0, 0, 255),
+ sf::Color(255, 0, 0, 255),
+ sf::Color(255, 255, 0, 255),
+ sf::Color(255, 255, 255, 255),
+ },
+ { 0.0f, 1.0f / 3.0f, 2.0f / 3.0f, 1.0f }
+ )
+{
+}
+
+InfernoColorMap::InfernoColorMap() : InterpolationColorMap(
+ {
+ sf::Color(0, 0, 0, 255),
+ sf::Color(40, 11, 84, 255),
+ sf::Color(101, 21, 110, 255),
+ sf::Color(159, 42, 99, 255),
+ sf::Color(212, 72, 66, 255),
+ sf::Color(245, 125, 21, 255),
+ sf::Color(250, 193, 39, 255),
+ sf::Color(252, 255, 164, 255),
+ },
+ {
+ 0.0f,
+ 0.142857142857143f,
+ 0.285714285714286f,
+ 0.428571428571429f,
+ 0.571428571428571f,
+ 0.714285714285714f,
+ 0.857142857142857f,
+ 1.0f
+ }
+ )
+{
+}
diff --git a/src/color-map.hpp b/src/color-map.hpp
index f466923..dd0072d 100644
--- a/src/color-map.hpp
+++ b/src/color-map.hpp
@@ -19,6 +19,12 @@ enum class ColorMapType {
/* MATLAB jet map */
kJet,
+ /* Hot */
+ kHot,
+
+ /* Inferno */
+ kInferno,
+
/* bicolor maps */
kGray,
kPurple,
@@ -135,4 +141,20 @@ public:
JetColorMap();
};
-#endif \ No newline at end of file
+/**
+ * Hot colormap
+ */
+class HotColorMap : public InterpolationColorMap {
+public:
+ HotColorMap();
+};
+
+/**
+ * Inferno colormap
+ */
+class InfernoColorMap: public InterpolationColorMap {
+public:
+ InfernoColorMap();
+};
+
+#endif
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 00e6bdd..7fdcdb5 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -41,7 +41,7 @@ Configuration::Configuration()
this->scale_unit_ = "FS";
this->scale_lower_bound_ = -120.0f;
this->scale_upper_bound_ = 0.0f;
- this->color_map_ = ColorMapType::kJet;
+ this->color_map_ = ColorMapType::kInferno;
this->background_color_ = sf::Color(0, 0, 0);
this->foreground_color_ = sf::Color(255, 255, 255);
this->has_axes_ = false;
@@ -196,7 +196,7 @@ Configuration::Build(int argc, const char **argv)
args::ValueFlag<std::string>
scale(display_opts, "string", "Display scale (default: dBFS,-120,0)", {'s', "scale"});
args::ValueFlag<std::string>
- colormap(display_opts, "string", "Colormap (default: jet)", {'c', "colormap"});
+ colormap(display_opts, "string", "Colormap (default: inferno)", {'c', "colormap"});
args::ValueFlag<std::string>
bgcolor(display_opts, "string", "Background color (default: 000000)", {"bg-color"});
args::ValueFlag<std::string>
@@ -429,6 +429,10 @@ Configuration::Build(int argc, const char **argv)
conf.color_map_ = ColorMapType::kGray;
} else if (cmap_str == "jet") {
conf.color_map_ = ColorMapType::kJet;
+ } else if (cmap_str == "hot") {
+ conf.color_map_ = ColorMapType::kHot;
+ } else if (cmap_str == "inferno") {
+ conf.color_map_ = ColorMapType::kInferno;
} else if (cmap_str == "purple") {
conf.color_map_ = ColorMapType::kPurple;
} else if (cmap_str == "blue") {