国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程

這篇具有很好參考價(jià)值的文章主要介紹了熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、前言

圖像配準(zhǔn)是一種圖像處理技術(shù),用于將多個(gè)場(chǎng)景對(duì)齊到單個(gè)集成圖像中。在這篇文章中,我將討論如何在可見(jiàn)光及其相應(yīng)的熱圖像上應(yīng)用圖像配準(zhǔn)。在繼續(xù)該過(guò)程之前,讓我們看看什么是熱圖像及其屬性。

二、熱紅外數(shù)據(jù)介紹

熱圖像本質(zhì)上通常是灰度圖像:黑色物體是冷的,白色物體是熱的,灰色的深度表示兩者之間的差異。 然而,一些熱像儀會(huì)為圖像添加顏色,以幫助用戶識(shí)別不同溫度下的物體。

熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程

圖1 左圖為可見(jiàn)光;有圖為熱紅外圖像

上面兩個(gè)圖像是可見(jiàn)的,它是對(duì)應(yīng)的熱圖像,你可以看到熱圖像有點(diǎn)被裁剪掉了。 這是因?yàn)樵跓釄D像中并沒(méi)有捕獲整個(gè)場(chǎng)景,而是將額外的細(xì)節(jié)作為元數(shù)據(jù)存儲(chǔ)在熱圖像中。

因此,為了執(zhí)行配準(zhǔn),我們要做的是找出可見(jiàn)圖像的哪一部分出現(xiàn)在熱圖像中,然后對(duì)圖像的該部分應(yīng)用配準(zhǔn)。

熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程

圖2 .與熱圖像匹配后裁剪的可見(jiàn)圖像

為了執(zhí)行上述操作,基本上包含兩張圖像,一張參考圖像和另一張要匹配的圖像。 因此,下面的算法會(huì)找出參考圖像的哪一部分出現(xiàn)在第二張圖像中,并為您提供匹配圖像部分的位置。

現(xiàn)在我們知道熱圖像中存在可見(jiàn)圖像的哪一部分,我們可以裁剪可見(jiàn)圖像,然后對(duì)生成的圖像進(jìn)行配準(zhǔn)。

三、配準(zhǔn)過(guò)程

為了執(zhí)行配準(zhǔn),我們要做的是找出將像素從可見(jiàn)圖像映射到熱圖像的特征點(diǎn),這在本文中進(jìn)行了解釋?zhuān)坏┪覀儷@得了一定數(shù)量的像素,我們就會(huì)停止并開(kāi)始映射這些像素,從而完成配準(zhǔn)過(guò)程完成了。

熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程

圖3 熱成像到可見(jiàn)光圖像配準(zhǔn)

一旦我們執(zhí)行了配準(zhǔn),如果匹配正確,我們將獲得具有配準(zhǔn)圖像的輸出,如下圖所示。

熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程

圖4 最終輸出結(jié)果

我對(duì) 400 張圖像的數(shù)據(jù)集執(zhí)行了此操作,獲得的結(jié)果非常好。 錯(cuò)誤數(shù)量很少,請(qǐng)參考下面的代碼,看看一切是如何完成的。


from __future__ import print_function
import numpy as np
import argparse
import glob
import cv2
import os

MAX_FEATURES = 500
GOOD_MATCH_PERCENT = 0.15

#function to align the thermal and visible image, it returns the homography matrix 
def alignImages(im1, im2,filename):
 
  # Convert images to grayscale
  im1Gray = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY)
  im2Gray = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY)
   
  # Detect ORB features and compute descriptors.
  orb = cv2.ORB_create(MAX_FEATURES)
  keypoints1, descriptors1 = orb.detectAndCompute(im1Gray, None)
  keypoints2, descriptors2 = orb.detectAndCompute(im2Gray, None)
   
  # Match features.
  matcher = cv2.DescriptorMatcher_create(cv2.DESCRIPTOR_MATCHER_BRUTEFORCE_HAMMING)
  matches = matcher.match(descriptors1, descriptors2, None)
   
  # Sort matches by score
  matches.sort(key=lambda x: x.distance, reverse=False)
 
  # Remove not so good matches
  numGoodMatches = int(len(matches) * GOOD_MATCH_PERCENT)
  matches = matches[:numGoodMatches]
 
  # Draw top matches
  imMatches = cv2.drawMatches(im1, keypoints1, im2, keypoints2, matches, None)
  if os.path.exists(os.path.join(args["output"],"registration")):
    pass
  else:
   os.mkdir(os.path.join(args["output"],"registration"))
  cv2.imwrite(os.path.join(args["output"],"registration",filename), imMatches)
   
  # Extract location of good matches
  points1 = np.zeros((len(matches), 2), dtype=np.float32)
  points2 = np.zeros((len(matches), 2), dtype=np.float32)
 
  for i, match in enumerate(matches):
    points1[i, :] = keypoints1[match.queryIdx].pt
    points2[i, :] = keypoints2[match.trainIdx].pt
   
  # Find homography
  h, mask = cv2.findHomography(points1, points2, cv2.RANSAC)
 
  # Use homography
  height, width, channels = im2.shape
  im1Reg = cv2.warpPerspective(im1, h, (width, height))
   
  return im1Reg, h

# construct the argument parser and parse the arguments
# run the file with python registration.py --image filename
ap = argparse.ArgumentParser()
# ap.add_argument("-t", "--template", required=True, help="Path to template image")
ap.add_argument("-i", "--image", required=False,default=r"熱紅外圖像的路徑",
    help="Path to images where thermal template will be matched")
ap.add_argument("-v", "--visualize",required=False,default=r"真彩色影像的路徑")
ap.add_argument("-o", "--output",required=False,default=r"保存路徑")
args = vars(ap.parse_args())

# put the thermal image in a folder named thermal and the visible image in a folder named visible with the same name
# load the image image, convert it to grayscale, and detect edges
template = cv2.imread(args["image"])
template = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
template = cv2.Canny(template, 50, 200)
(tH, tW) = template.shape[:2]
cv2.imshow("Template", template)
#cv2.waitKey(0)

# loop over the images to find the template in

# load the image, convert it to grayscale, and initialize the
# bookkeeping variable to keep track of the matched region
image = cv2.imread(args["visualize"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
found = None

# loop over the scales of the image
for scale in np.linspace(0.2, 1.0, 20)[::-1]:
    # resize the image according to the scale, and keep track
    # of the ratio of the resizing
    resized = cv2.resize(gray, (int(gray.shape[1] * scale),int(gray.shape[0] * scale)))
    r = gray.shape[1] / float(resized.shape[1])

    # if the resized image is smaller than the template, then break
    # from the loop
    if resized.shape[0] < tH or resized.shape[1] < tW:
        break

    # detect edges in the resized, grayscale image and apply template
    # matching to find the template in the image
    edged = cv2.Canny(resized, 50, 200)
    result = cv2.matchTemplate(edged, template, cv2.TM_CCOEFF)
    (_, maxVal, _, maxLoc) = cv2.minMaxLoc(result)

    # check to see if the iteration should be visualized
    if True:
        # draw a bounding box around the detected region
        clone = np.dstack([edged, edged, edged])
        cv2.rectangle(clone, (maxLoc[0], maxLoc[1]),
            (maxLoc[0] + tW, maxLoc[1] + tH), (0, 0, 255), 2)
        cv2.imshow("Visualize", clone)
        #cv2.waitKey(0)

    # if we have found a new maximum correlation value, then update
    # the bookkeeping variable
    if found is None or maxVal > found[0]:
        found = (maxVal, maxLoc, r)

# unpack the bookkeeping variable and compute the (x, y) coordinates
# of the bounding box based on the resized ratio
(_, maxLoc, r) = found
(startX, startY) = (int(maxLoc[0] * r), int(maxLoc[1] * r))
(endX, endY) = (int((maxLoc[0] + tW) * r), int((maxLoc[1] + tH) * r))

# draw a bounding box around the detected result and display the image
cv2.rectangle(image, (startX, startY), (endX, endY), (0, 0, 255), 2)
crop_img = image[startY:endY, startX:endX]
#cv2.imshow("Image", image)
cv2.imshow("Crop Image", crop_img)
#cv2.waitKey(0)

#name = r"E:\temp\data5/thermal/"+args["image"]+'.JPG'
thermal_image = cv2.imread(args["image"], cv2.IMREAD_COLOR)

#cropping out the matched part of the thermal image
crop_img = cv2.resize(crop_img, (thermal_image.shape[1], thermal_image.shape[0]))

#cropped image will be saved in a folder named output
if os.path.exists(os.path.join(args["output"],"process")):
   pass
else:
   os.mkdir(os.path.join(args["output"],"process"))
cv2.imwrite(os.path.join(args["output"],"process", os.path.basename(args["visualize"])),crop_img)

#both images are concatenated and saved in a folder named results
final = np.concatenate((crop_img, thermal_image), axis = 1)
if os.path.exists(os.path.join(args["output"],"results")):
   pass
else:
   os.mkdir(os.path.join(args["output"],"results"))
cv2.imwrite(os.path.join(args["output"],"results", os.path.basename(args["visualize"])),final)

#cv2.waitKey(0)
# Registration
# Read reference image
refFilename =  args["image"]
print("Reading reference image : ", refFilename)
imReference = cv2.imread(refFilename, cv2.IMREAD_COLOR)

# Read image to be aligned
imFilename = os.path.join(args["output"],"process", os.path.basename(args["visualize"]))
print("Reading image to align : ", imFilename);  
im = cv2.imread(imFilename, cv2.IMREAD_COLOR)
file_name=os.path.basename(args["image"])+'_registration.JPG'
imReg, h = alignImages(im,imReference,file_name)
cv2.imwrite(os.path.join(args["output"],"results", os.path.basename(args["image"])+'_result.JPG'),imReg)
print("Estimated homography : \n",  h)

我們已經(jīng)成功地進(jìn)行了熱到可見(jiàn)圖像配準(zhǔn)。你可以用你的數(shù)據(jù)集來(lái)嘗試一下,然后看看結(jié)果。

后續(xù):

????????因opencv版本問(wèn)題做了修改,最終結(jié)果可以在registration和result保存路徑下查看,其中opencv原因需要英文路徑,調(diào)用使用方法如下:

python .\main.py -i “熱紅外影像路徑” -v “真彩色影像路徑” -o “保存路徑”文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-469999.html

到了這里,關(guān)于熱紅外相機(jī)圖片與可見(jiàn)光圖片配準(zhǔn)教程的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 基于LED或紅外激光的可見(jiàn)光音頻系統(tǒng)

    基于LED或紅外激光的可見(jiàn)光音頻系統(tǒng)

    ? 1 前言 ? ? ? ??可見(jiàn)光通信技術(shù) , 簡(jiǎn)稱(chēng)為 VLC ,這種技術(shù)手段在無(wú)線通信領(lǐng)域中最新成型,便能得以快速發(fā)展壯大。在接下來(lái)的一段時(shí)間之內(nèi),無(wú)論是在哪個(gè)領(lǐng)域,該項(xiàng)技術(shù)肯定會(huì)有很大的發(fā)展,跟現(xiàn)有的無(wú)線通信技術(shù)形成強(qiáng)有力的競(jìng)爭(zhēng),對(duì)人類(lèi)文明的進(jìn)步產(chǎn)生巨大的影響

    2024年02月11日
    瀏覽(72)
  • 利用紅外-可見(jiàn)光圖像數(shù)據(jù)集OTCBVS打通圖像融合、目標(biāo)檢測(cè)和目標(biāo)跟蹤

    利用紅外-可見(jiàn)光圖像數(shù)據(jù)集OTCBVS打通圖像融合、目標(biāo)檢測(cè)和目標(biāo)跟蹤

    本文記錄在云服務(wù)器autodl上選擇安裝cuda、cudnn開(kāi)始,部署相同視角、相同時(shí)間、相同地點(diǎn)拍攝的紅外和可見(jiàn)光圖像數(shù)據(jù)集OTCBVS在Github目前開(kāi)源的圖像融合PIAFusion、目標(biāo)檢測(cè)Yolo-v4、目標(biāo)跟蹤DeepSort算法上實(shí)現(xiàn)單數(shù)據(jù)集貫通。 本文只做到以下幾點(diǎn): 1、列舉常見(jiàn)紅外-可見(jiàn)光圖像數(shù)

    2024年02月04日
    瀏覽(20)
  • 圖像融合論文閱讀:CrossFuse: 一種基于交叉注意機(jī)制的紅外與可見(jiàn)光圖像融合方法

    圖像融合論文閱讀:CrossFuse: 一種基于交叉注意機(jī)制的紅外與可見(jiàn)光圖像融合方法

    @article{li2024crossfuse, title={CrossFuse: A novel cross attention mechanism based infrared and visible image fusion approach}, author={Li, Hui and Wu, Xiao-Jun}, journal={Information Fusion}, volume={103}, pages={102147}, year={2024}, publisher={Elsevier} } 論文級(jí)別:SCI A1 影響因子:18.6 ??[論文下載地址] ??[代碼下載地址] 以往的交

    2024年01月15日
    瀏覽(27)
  • ADAS-可見(jiàn)光相機(jī)之Cmos Image Sensor

    ADAS-可見(jiàn)光相機(jī)之Cmos Image Sensor

    “ 可見(jiàn)光相機(jī)在日常生活、工業(yè)生產(chǎn)、智能制造等應(yīng)用有著重要的作用。在ADAS中更是扮演著重要的角色,如tesla model系列全車(chē)身10多個(gè)相機(jī),不斷感知周?chē)澜?。本文著重講解下可見(jiàn)光相機(jī)中的CIS(CMOS Image Sensor)?!?光是一種電磁波,自然界的光是由各種波長(zhǎng)的電磁波組成,

    2024年02月09日
    瀏覽(26)
  • 【圖像融合】小波變換可見(jiàn)光與紅外光圖像融合(帶面板)【含GUI Matlab源碼 701期】

    【圖像融合】小波變換可見(jiàn)光與紅外光圖像融合(帶面板)【含GUI Matlab源碼 701期】

    ?博主簡(jiǎn)介:熱愛(ài)科研的Matlab仿真開(kāi)發(fā)者,修心和技術(shù)同步精進(jìn),Matlab項(xiàng)目合作可私信。 ??個(gè)人主頁(yè):海神之光 ??代碼獲取方式: 海神之光Matlab王者學(xué)習(xí)之路—代碼獲取方式 ??座右銘:行百里者,半于九十。 更多Matlab仿真內(nèi)容點(diǎn)擊?? Matlab圖像處理(進(jìn)階版) 路徑規(guī)劃

    2024年02月19日
    瀏覽(32)
  • 【紅外與可見(jiàn)光圖像融合】離散平穩(wěn)小波變換域中基于離散余弦變換和局部空間頻率的紅外與視覺(jué)圖像融合方法(Matlab代碼實(shí)現(xiàn))

    【紅外與可見(jiàn)光圖像融合】離散平穩(wěn)小波變換域中基于離散余弦變換和局部空間頻率的紅外與視覺(jué)圖像融合方法(Matlab代碼實(shí)現(xiàn))

    ????????? 歡迎來(lái)到本博客 ???????? ??博主優(yōu)勢(shì): ?????? 博客內(nèi)容盡量做到思維縝密,邏輯清晰,為了方便讀者。 ?? 座右銘: 行百里者,半于九十。 ?????? 本文目錄如下: ?????? 目錄 ??1 概述 ??2 運(yùn)行結(jié)果 ??3?參考文獻(xiàn) ??4 Matlab代碼及文獻(xiàn) 基于

    2024年02月07日
    瀏覽(19)
  • 圖像融合論文閱讀:CS2Fusion: 通過(guò)估計(jì)特征補(bǔ)償圖譜實(shí)現(xiàn)自監(jiān)督紅外和可見(jiàn)光圖像融合的對(duì)比學(xué)習(xí)

    圖像融合論文閱讀:CS2Fusion: 通過(guò)估計(jì)特征補(bǔ)償圖譜實(shí)現(xiàn)自監(jiān)督紅外和可見(jiàn)光圖像融合的對(duì)比學(xué)習(xí)

    @article{wang2024cs2fusion, title={CS2Fusion: Contrastive learning for Self-Supervised infrared and visible image fusion by estimating feature compensation map}, author={Wang, Xue and Guan, Zheng and Qian, Wenhua and Cao, Jinde and Liang, Shu and Yan, Jin}, journal={Information Fusion}, volume={102}, pages={102039}, year={2024}, publisher={Elsevier} } 論文級(jí)

    2024年01月22日
    瀏覽(35)
  • 【圖像融合】Dif-Fusion:基于擴(kuò)散模型的紅外/可見(jiàn)圖像融合方法

    【圖像融合】Dif-Fusion:基于擴(kuò)散模型的紅外/可見(jiàn)圖像融合方法

    顏色在人類(lèi)的視覺(jué)感知中起著重要的作用,反映了物體的光譜。然而, 現(xiàn)有的紅外和可見(jiàn)光圖像融合方法很少探索如何直接處理多光譜/通道數(shù)據(jù),并實(shí)現(xiàn)較高的彩色保真度 。本文提出了一種 利用擴(kuò)散模型diffusion來(lái)生成多通道輸入數(shù)據(jù)的分布 ,提高了多源信息聚合的能力和

    2024年02月09日
    瀏覽(103)
  • Unity判斷物體是否被某個(gè)相機(jī)可見(jiàn)

    第一種方式: 將物體的世界坐標(biāo)轉(zhuǎn)換為視口坐標(biāo)(Viewport Coordinates),得到的坐標(biāo)值會(huì)在[0,1]的范圍內(nèi),表示物體在相機(jī)視口中的位置。如果物體的位置在這個(gè)范圍內(nèi),就說(shuō)明它被相機(jī)看到了。 第二種方式: 判斷物體是否完全在相機(jī)的視錐體內(nèi),可以使用相機(jī)的GeometryUtilit

    2024年02月05日
    瀏覽(30)
  • 相機(jī)可見(jiàn)區(qū)域,使用鼠標(biāo)拖拽模型

    向量 射線檢測(cè) 坐標(biāo)轉(zhuǎn)換 使用 射線檢測(cè) 獲取射線檢測(cè)點(diǎn)與模型對(duì)象之間的偏移量 (世界空間) 使用 相機(jī)的坐標(biāo)轉(zhuǎn)換 獲取檢測(cè)點(diǎn)與鼠標(biāo)位置之間的偏移量 (屏幕空間) 拖拽時(shí),更新模型位置

    2024年02月14日
    瀏覽(19)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包