unsigned compare(image_type const & actual, boost::filesystem::path const& reference) const { std::ifstream stream(reference.string().c_str(), std::ios_base::in | std::ios_base::binary); if (!stream) { throw std::runtime_error("Could not open: " + reference.string()); } std::string expected(std::istreambuf_iterator<char>(stream.rdbuf()), std::istreambuf_iterator<char>()); return std::max(actual.size(), expected.size()) - std::min(actual.size(), expected.size()); }
void RSS_MultiSensor_PCA_Fusion(const image_type &image1, const image_type &image2, image_type &result) { using namespace rss; rss::ImageVector<image_type> input_vector; input_vector.push_back(image1); if(image1.size() != image2.size()) { BilinearInterpolation<image_type> interpolate(image1.size()); image_type temp; interpolate(image2, temp); input_vector.push_back(temp); } else { input_vector.push_back(image2); } PCAFusion<image_type> fusion(image1.width(), image1.height()); fusion(input_vector, result); }
void RSS_MultiSensor_Wavelet_Fusion(const image_type &image1, const image_type &image2, image_type &result) { using namespace rss; rss::ImageVector<image_type> input_vector; input_vector.push_back(image1); if(image1.size() != image2.size()) { BilinearInterpolation<image_type> interpolate(image1.size()); image_type result; interpolate(image2, result); input_vector.push_back(result); } else { input_vector.push_back(image2); } WaveletFusion<image_type> fusion(image1.size(), FilterSet::Haar()); fusion(input_vector, result); }
void RSS_MultiSensor_Contour_Register(const image_type &VLImage, const image_type &IRImage, float para[6], image_type &result) { using namespace rss; ContourRegister contour_register(HomoModel::Similarity, 3.1, 0.0, 0.0, 0.0, 30, 0.18, 0.8, 0.5); HomoModel model; contour_register(VLImage, IRImage,model); HomoTrans<image_type> homo_trans(model, VLImage.size()); homo_trans.inverse(IRImage, result); }
unsigned compare(image_type const & actual, boost::filesystem::path const& reference) const { std::ifstream stream(reference.string().c_str(),std::ios_base::in|std::ios_base::binary); if (!stream.is_open()) { throw std::runtime_error("could not open: '" + reference.string() + "'"); } std::string expected(std::istreambuf_iterator<char>(stream.rdbuf()),(std::istreambuf_iterator<char>())); stream.close(); return std::fabs(actual.size() - expected.size()); }
void RSS_MultiSensor_FFT_Register(const image_type &VLImage, const image_type &IRImage, float para[6], image_type &result) { using namespace rss; image_type temp; if(para) { double scale1 = para[0] / para[3] * para[4] / para[1] * VLImage.width() / IRImage.width(); double scale2 = para[0] / para[3] * para[5] / para[2] * VLImage.height() / IRImage.height(); double scale = sqrt(scale1*scale2); HomoModel pre_trans_model; pre_trans_model.SetSimilarity(scale, 0, IRImage.width() * (1 - scale) / 2.0, IRImage.height() * (1 - scale) / 2.0); HomoTrans<image_type> pre_trans(pre_trans_model, VLImage.size()); pre_trans.operator ()(IRImage, temp); } else { temp = IRImage; } HomoModel model; SimilarityEstimation(true, true, false, SimilarityEstimation::OP_NONE, SimilarityEstimation::FILTER_NONE)(VLImage, temp, model); HomoTrans<image_type> homo_trans(model, VLImage.size()); homo_trans.operator()(temp, result); }
void operator()(image_type& src) { typedef tipl::image<typename image_type::value_type,image_type::dimension> image_buf_type; image_buf_type gx; gradient_2x(src,gx); image_buf_type gy; gradient_2y(src,gy); for(size_t index = 0;index < src.size();++index) { float fx = gx[index]; float fy = gy[index]; src[index] = std::sqrt(fx*fx+fy*fy); } }
void fft_shift_z(image_type& I) { int wh = I.plane_size(); int half_size = I.size() >> 1; int half_size_1 = half_size-wh; int quater_size = half_size >> 1; typename image_type::iterator iter1 = I.begin(); typename image_type::iterator iter2 = iter1+half_size; typename image_type::iterator end = iter1+wh; for(;iter1 != end;++iter1,++iter2) { for(int z = 0,rz = half_size_1;z < quater_size;z+=wh,rz-=wh) { std::swap(iter1[z],iter1[rz]); std::swap(iter2[z],iter2[rz]); } } }
void RSS_MultiSensor_Fleet_Region(const image_type &VLImage, const image_type &IRImage, image_type &result1, image_type &result2, float regions[61]) { using namespace rss; rss::FleetEdgeDetector detector; detector(IRImage, result1); // result1 holds the fution image RSS_MultiSensor_Wavelet_Fusion(VLImage,IRImage,result1); // put the image of result into the Memeory dc HDC m_hDC = CreateCompatibleDC(::GetDC(NULL)); HBITMAP m_hBitmap = CreateCompatibleBitmap(::GetDC(NULL),result1.width(),result1.height()); HPEN m_hPen = CreatePen(PS_SOLID,1,RGB(255,255,255)); HBRUSH m_hBrush = (HBRUSH)GetStockObject(NULL_BRUSH); SelectObject(m_hDC,m_hBitmap); SelectObject(m_hDC,m_hPen); SelectObject(m_hDC,m_hBrush); SetBkMode(m_hDC,TRANSPARENT); SetTextColor(m_hDC,RGB(255,255,255)); for (int x = 0; x < result1.width(); x ++) { for (int y = 0; y < result1.height(); y ++) { int gray = rss::pixel_cast<rss::GrayPixel>(result1(x,y)); COLORREF color = RGB(gray,gray,gray); SetPixel(m_hDC,x,y,color); } } ObjectiveRegions r = detector.objective_region(); regions[0] = min(20u, static_cast<float>(r.size())); for(size_t i = 0; i < min(20U, r.size()); i++) { regions[i*3 + 1] = r[i].center.x(); regions[i*3 + 2] = r[i].center.y(); regions[i*3 + 3] = r[i].reliability; } // fill the background result2.resize(result1.size()); for (int x = 0; x < result2.width(); x ++) for (int y = 0; y < result2.height(); y ++) result2(x,y) = 0; // file the sensitive region for (int i = 0; i < min(20U,r.size()); i ++) { ::Rectangle(m_hDC,r[i].region.left(),r[i].region.top(),r[i].region.right(),r[i].region.bottom()); int dx = (r[i].region.right() - r[i].region.left()) / 2; int dy = (r[i].region.bottom() - r[i].region.top()) / 2; char* str = RSS_MultiSensor_Get_String(i+1); TextOut(m_hDC,r[i].region.left()+dx,r[i].region.top()+dy,str,strlen(str)); image_type region; region.resize(r[i].region.size()); for (int x = r[i].region.left(); x < r[i].region.right(); x ++) { for (int y = r[i].region.top(); y < r[i].region.bottom(); y ++) { region(x-r[i].region.left(),y-r[i].region.top()) = VLImage(x,y); } } RegionGrow<image_type> regionGrow(1.0/5.0,10); image_type region_result; regionGrow(region,region_result); for (int x = r[i].region.left(); x < r[i].region.right(); x ++) { for (int y = r[i].region.top(); y < r[i].region.bottom(); y ++) { result2(x,y) = region_result(x-r[i].region.left(),y-r[i].region.top()); } } } // put the image of Memory dc back to result1 for (int x = 0; x < VLImage.width(); x ++) { for (int y = 0; y < VLImage.height(); y ++) { result1(x,y) = rss::pixel_cast<rss::RealPixel>GetRValue(GetPixel(m_hDC,x,y)); } } DeleteObject(m_hDC); DeleteObject(m_hBitmap); DeleteObject(m_hPen); DeleteObject(m_hBrush); }