Use OpenCV to stitch 2d histograms – Merge cv2.detail.MatchesInfo

I am attempting to stitch multiple 2d histograms (2d data arrays) together for which the horizontal and vertical axes of the histograms are spatial coordinates, but the origin for the different histograms may vary. This task therefore requires affine transformations after identifying matching features, for which a slightly modified OpenCV stitching pipeline (https://github.com/opencv/opencv/blob/4.x/samples/python/stitching_detailed.py) is used.

I first transform this grayscale data to RGB format that CV is expecting (see below), then apply the stitching pipeline. The stitched RGB image is finally converted back to a 2d array using code from a different SO thread: /a/71649250/12533405

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from matplotlib.colors import LinearSegmentedColormap
from matplotlib._cm import _jet_data
from matplotlib import cm
import numpy as np
import cv2 as cv
def load_data(*files):
data = dict()
maxvals = list()
arrays = list()
for file in list(files):
arr = np.loadtxt(file)
arrays.append(arr)
maxvals.append(np.max(arr))
maxval = max(maxvals)
mymap = cm.get_cmap(LinearSegmentedColormap('myjet',_jet_data,N=10000))
for idx,arr in enumerate(arrays):
img = mymap(np.flipud(arr)/maxval,bytes=True)[:,:,[2,1,0]]
data[list(files)[idx]] = cv.resize(img, (0,0), fx=3, fy=3)
return data, maxval
</code>
<code>from matplotlib.colors import LinearSegmentedColormap from matplotlib._cm import _jet_data from matplotlib import cm import numpy as np import cv2 as cv def load_data(*files): data = dict() maxvals = list() arrays = list() for file in list(files): arr = np.loadtxt(file) arrays.append(arr) maxvals.append(np.max(arr)) maxval = max(maxvals) mymap = cm.get_cmap(LinearSegmentedColormap('myjet',_jet_data,N=10000)) for idx,arr in enumerate(arrays): img = mymap(np.flipud(arr)/maxval,bytes=True)[:,:,[2,1,0]] data[list(files)[idx]] = cv.resize(img, (0,0), fx=3, fy=3) return data, maxval </code>
from matplotlib.colors import LinearSegmentedColormap
from matplotlib._cm import _jet_data
from matplotlib import cm
import numpy as np
import cv2 as cv

def load_data(*files):
    
    data = dict()
    maxvals = list()
    arrays = list()
    
    for file in list(files):
        arr = np.loadtxt(file)
        arrays.append(arr)
        maxvals.append(np.max(arr))
    
    maxval = max(maxvals)

    mymap = cm.get_cmap(LinearSegmentedColormap('myjet',_jet_data,N=10000))

    for idx,arr in enumerate(arrays):
        img = mymap(np.flipud(arr)/maxval,bytes=True)[:,:,[2,1,0]]

        data[list(files)[idx]] = cv.resize(img, (0,0), fx=3, fy=3)
        
    return data, maxval

This routine works quite well if the processed data exhibits enough overlap with matchable features.

On to the problem

The spatial histogram data is actually 3D, meaning that the 2d array produced for processing is simply a summation along the third axis for a specific region of interest. Summing over a different region of interest would produce a very different false-color image with the same spatial coordinates.

Question: While it is possible to extract the camera settings (estimator) for one region of interest and apply them to the warper for a different region of interest, I wonder how it would be possible to construct the camera settings taking multiple regions of interest into account simultaneously?

Currently, orb finds features for each image in one region of interest, then the detail_AffineBestOf2NearestMatcher finds matching features and feeds to the estimator. I was hoping that multiple instances of cv2.detail.MatchesInfo corresponding to different regions of interest could be merged. Is that possible?

It seems OpenCV is quite useful to approach this problem but I am also open to different implementations.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật