MCPcopy Create free account
hub / github.com/colmap/colmap / ApplyGlobalColorCorrection

Function ApplyGlobalColorCorrection

src/colmap/mvs/texture_mapping.cc:745–972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743}
744
745void ApplyGlobalColorCorrection(
746 Bitmap* atlas,
747 const PlyMesh& mesh,
748 const std::vector<FaceRegion>& regions,
749 const std::vector<RegionProjection>& projections,
750 const AtlasLayout& layout,
751 const std::vector<Image>& images,
752 const FaceAdjacencyMap& adjacency,
753 const std::vector<int>& view_per_face,
754 const std::vector<bool>& baked_mask,
755 const MeshTextureMappingOptions& options) {
756 struct SeamEdge {
757 size_t face_l;
758 size_t face_r;
759 size_t vert_a;
760 size_t vert_b;
761 };
762
763 const size_t num_faces = mesh.faces.size();
764 std::vector<SeamEdge> seam_edges;
765 seam_edges.reserve(num_faces);
766
767 for (size_t fi = 0; fi < num_faces; ++fi) {
768 if (view_per_face[fi] < 0) continue;
769 const std::array<size_t, 3> idx = GetFaceIndices(mesh.faces[fi]);
770 for (int e = 0; e < 3; ++e) {
771 const size_t va = idx[e];
772 const size_t vb = idx[(e + 1) % 3];
773 const uint64_t ekey = EdgeKey(va, vb);
774
775 for (const size_t ni : adjacency[fi]) {
776 if (ni <= fi) continue;
777 if (view_per_face[ni] < 0) continue;
778 if (view_per_face[ni] == view_per_face[fi]) continue;
779
780 const std::array<size_t, 3> nidx = GetFaceIndices(mesh.faces[ni]);
781 bool shares_edge = false;
782 for (int ne = 0; ne < 3; ++ne) {
783 if (EdgeKey(nidx[ne], nidx[(ne + 1) % 3]) == ekey) {
784 shares_edge = true;
785 break;
786 }
787 }
788 if (shares_edge) {
789 seam_edges.push_back({fi, ni, va, vb});
790 }
791 }
792 }
793 }
794
795 if (seam_edges.empty()) return;
796
797 // Build per-region vertex-to-variable mapping.
798 struct RegionVertexMap {
799 std::unordered_map<size_t, size_t> vert_to_var;
800 };
801 std::vector<RegionVertexMap> region_vert_maps(regions.size());
802

Callers 1

MeshTextureMappingFunction · 0.85

Calls 14

GetFaceIndicesFunction · 0.85
EdgeKeyFunction · 0.85
GetVertexFunction · 0.85
ProjectPointFunction · 0.85
ComputeAtlasVertsFunction · 0.85
BarycentricFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
GetPMethod · 0.80
InterpolateBilinearMethod · 0.80
GetPixelMethod · 0.80
SetPixelMethod · 0.80

Tested by

no test coverage detected