Skip to content

Commit f8c9425

Browse files
authored
Merge pull request #42 from Digitelektro/develop
Develop
2 parents 4faaac4 + ac7470f commit f8c9425

6 files changed

Lines changed: 49 additions & 18 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ if(UNIX AND NOT APPLE)
151151
SET(CPACK_GENERATOR "DEB")
152152
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
153153
SET(CPACK_PACKAGE_VERSION_MINOR "4")
154-
SET(CPACK_PACKAGE_VERSION_PATCH "0")
154+
SET(CPACK_PACKAGE_VERSION_PATCH "1")
155155
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Digitelektro")
156156
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Digitelektro/MeteorDemod")
157157
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Russian Meteor M2 weather satellite data decoder")

common/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
#define VERSION_MAJOR 2
55
#define VERSION_MINOR 4
6-
#define VERSION_FIX 0
6+
#define VERSION_FIX 1
77

88
#endif // VERSION_H

imageproc/spreadimage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ cv::Mat SpreadImage::mercatorProjection(const std::list<cv::Mat> &images, const
309309

310310
cv::Mat grayScale1;
311311
cv::Mat alpha1;
312-
cv::bilateralFilter(composite, grayScale1, 19, 75, 75);
312+
cv::medianBlur(composite, grayScale1, 5);
313313
cv::cvtColor(grayScale1, grayScale1, cv::COLOR_BGR2GRAY);
314314

315315
cv::threshold(grayScale1, alpha1, 0, 255, cv::THRESH_BINARY);
316316
grayScale1.release();
317317

318318
cv::Mat grayScale2;
319319
cv::Mat alpha2;
320-
cv::bilateralFilter(*it, grayScale2, 19, 75, 75);
320+
cv::medianBlur(*it, grayScale2, 5);
321321
cv::cvtColor(grayScale2, grayScale2, cv::COLOR_BGR2GRAY);
322322

323323
cv::threshold(grayScale2, alpha2, 0, 255, cv::THRESH_BINARY);
@@ -565,15 +565,15 @@ cv::Mat SpreadImage::equidistantProjection(const std::list<cv::Mat> &images, con
565565

566566
cv::Mat grayScale1;
567567
cv::Mat alpha1;
568-
cv::bilateralFilter(composite, grayScale1, 19, 75, 75);
568+
cv::medianBlur(composite, grayScale1, 5);
569569
cv::cvtColor(grayScale1, grayScale1, cv::COLOR_BGR2GRAY);
570570

571571
cv::threshold(grayScale1, alpha1, 0, 255, cv::THRESH_BINARY);
572572
grayScale1.release();
573573

574574
cv::Mat grayScale2;
575575
cv::Mat alpha2;
576-
cv::bilateralFilter(*it, grayScale2, 19, 75, 75);
576+
cv::medianBlur(*it, grayScale2, 5);
577577
cv::cvtColor(grayScale2, grayScale2, cv::COLOR_BGR2GRAY);
578578

579579
cv::threshold(grayScale2, alpha2, 0, 255, cv::THRESH_BINARY);

imageproc/threatimage.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,31 @@ cv::Mat ThreatImage::irToRain(const cv::Mat &irImage, const cv::Mat &ref)
8282
return rainImage;
8383
}
8484

85+
cv::Mat ThreatImage::invertIR(const cv::Mat &image)
86+
{
87+
cv::Mat result = cv::Mat::zeros(image.size(), image.type());
88+
cv::Mat grayScale;
89+
cv::Mat alpha;
90+
91+
cv::cvtColor(image, grayScale, cv::COLOR_BGR2GRAY);
92+
std::vector<std::vector<cv::Point> > contours;
93+
cv::findContours(grayScale, contours, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE);
94+
for (std::size_t i = 0; i < contours.size(); i++) {
95+
cv::drawContours(grayScale, contours, i, cv::Scalar(255, 255, 255), -1);
96+
}
97+
98+
//create mask
99+
cv::threshold(grayScale, alpha, 0, 255, cv::THRESH_BINARY);
100+
101+
//invert colors
102+
cv::bitwise_not(image, image);
103+
104+
//apply mask
105+
cv::bitwise_and(image, image, result, alpha);
106+
107+
return result;
108+
}
109+
85110
cv::Mat ThreatImage::addRainOverlay(const cv::Mat &image, const cv::Mat &rain)
86111
{
87112
cv::Mat rainImage = cv::Mat::zeros(image.size(), image.type());

imageproc/threatimage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ThreatImage
2121
static void fillBlackLines(cv::Mat &image, int minimumHeight, int maximumHeight);
2222
static cv::Mat irToTemperature(const cv::Mat &irImage, const cv::Mat &ref);
2323
static cv::Mat irToRain(const cv::Mat &irImage, const cv::Mat &ref);
24+
static cv::Mat invertIR(const cv::Mat &image);
2425
static cv::Mat addRainOverlay(const cv::Mat &image, const cv::Mat &rain);
2526
static cv::Mat gamma(const cv::Mat &image, double gamma);
2627
static void drawWatermark(cv::Mat image, const std::string &date);

main.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "deinterleaver.h"
88
#include "pixelgeolocationcalculator.h"
99

10+
#include <map>
11+
#include <tuple>
1012
#include <iostream>
1113
#include <fstream>
1214
#include <sstream>
@@ -296,7 +298,7 @@ int main(int argc, char *argv[])
296298
cv::Mat thermalImage = ThreatImage::irToTemperature(irImage, thermalRef);
297299
imagesToSpread.push_back(ImageForSpread(thermalImage, "thermal_"));
298300

299-
cv::bitwise_not(irImage, irImage);
301+
irImage = ThreatImage::invertIR(irImage);
300302
irImage = ThreatImage::gamma(irImage, 1.8);
301303
imagesToSpread.push_back(ImageForSpread(irImage, "IR_"));
302304

@@ -351,7 +353,7 @@ int main(int argc, char *argv[])
351353
cv::Mat rainRef = cv::imread(mSettings.getResourcesPath() + "rain.bmp");
352354
cv::Mat rainOverlay = ThreatImage::irToRain(ch68, rainRef);
353355

354-
cv::bitwise_not(ch68, ch68);
356+
ch68 = ThreatImage::invertIR(ch68);
355357
ch68 = ThreatImage::gamma(ch68, 1.8);
356358
imagesToSpread.push_back(ImageForSpread(ch68, "IR_"));
357359

@@ -506,7 +508,7 @@ int main(int argc, char *argv[])
506508
if(images68.size() > 1 && images68.size() == geolocationCalculators68.size()) {
507509
if(mSettings.compositeEquadistantProjection() || mSettings.compositeMercatorProjection()) {
508510
for(auto &img : images68) {
509-
cv::bitwise_not(img, img);
511+
img = ThreatImage::invertIR(img);
510512
img = ThreatImage::gamma(img, 1.8);
511513
}
512514
}
@@ -569,6 +571,7 @@ int main(int argc, char *argv[])
569571
void searchForImages(std::list<cv::Mat> &imagesOut, std::list<PixelGeolocationCalculator> &geolocationCalculatorsOut, const std::string &channelName)
570572
{
571573
std::time_t now = std::time(nullptr);
574+
std::map<std::time_t, std::tuple<std::string, std::string>> map;
572575

573576
for(const auto & entry : fs::directory_iterator(mSettings.getOutputPath())) {
574577
auto ftime = fs::last_write_time(entry);
@@ -584,27 +587,29 @@ void searchForImages(std::list<cv::Mat> &imagesOut, std::list<PixelGeolocationCa
584587
fs::path fileJPG(folder + "/" + fileNameBase + "_" + channelName + ".jpg");
585588

586589
if(fs::exists(fileJPG)) {
587-
std::cout << "" << fileJPG << " " << std::endl;
588-
589-
imagesOut.emplace_back(cv::imread(fileJPG.generic_string()));
590-
geolocationCalculatorsOut.emplace_back(PixelGeolocationCalculator::load(entry.path().generic_string()));
591-
590+
map[cftime] = std::make_tuple(entry.path().generic_string(), fileJPG);
592591
break;
593592
}
594593

595594
fs::path fileBMP(folder + "/" + fileNameBase + "_" + channelName + ".bmp");
596595

597596
if(fs::exists(fileBMP)) {
598-
std::cout << "" << fileBMP << " " << std::endl;
599-
600-
imagesOut.emplace_back(cv::imread(fileBMP.generic_string()));
601-
geolocationCalculatorsOut.emplace_back(PixelGeolocationCalculator::load(entry.path().generic_string()));
597+
map[cftime] = std::make_tuple(entry.path().generic_string(), fileBMP);
602598

603599
break;
604600
}
605601
} while(false);
606602
}
607603
}
604+
605+
if(map.size() > 2) {
606+
for (auto const &[time, paths] : map) {
607+
std::cout << std::get<1>(paths) << std::endl;
608+
609+
geolocationCalculatorsOut.emplace_back(PixelGeolocationCalculator::load(std::get<0>(paths)));
610+
imagesOut.emplace_back(cv::imread(std::get<1>(paths)));
611+
}
612+
}
608613
}
609614

610615
void saveImage(const std::string fileName, const cv::Mat &image)

0 commit comments

Comments
 (0)