久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 python 中將圖像劃分為 5x5 塊并計(jì)算每個(gè)塊的直

Divide an image into 5x5 blocks in python and compute histogram for each block(在 python 中將圖像劃分為 5x5 塊并計(jì)算每個(gè)塊的直方圖)
本文介紹了在 python 中將圖像劃分為 5x5 塊并計(jì)算每個(gè)塊的直方圖的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

使用 Python,我必須:

Using Python, I have to:

  • Test_ImageReference_image 分成 5x5 塊,
  • 計(jì)算每個(gè)塊的直方圖,并將其與另一個(gè)圖像中的相同塊進(jìn)行比較.
    例如:image1(1,1)image2(1,1).
  • 比較兩張圖片的相似度(應(yīng)該是變換不變的).
  • Divide a Test_Image and Reference_image into 5x5 blocks,
  • Compute a histogram for each block, and compare it with the same block in the other image.
    For Example: image1(1,1) with image2(1,1).
  • Compare the similarity between two images (should be transform invariant).

到目前為止,我已經(jīng)使用 hist=numpy.histogram(image,bins=256)

So far, I have calculated the histogram of the whole image using hist=numpy.histogram(image,bins=256)

我想分割圖像,然后計(jì)算所有這些塊的直方圖.我還想使用 Bhattacharya 的系數(shù)來(lái)衡量相似度.

I want to divide an image, and later compute the histogram for all those blocks . I also want to use Bhattacharya's coefficient to measure the similarity.

誰(shuí)能指導(dǎo)我如何通過(guò)這個(gè)?在此先感謝:)

Can anyone guide me with how to go through this one? Thanks in advance :)

推薦答案

不知道是不是你要找的這樣的東西,這是蠻力版本.它可能很慢.但它完成了工作但是,您必須決定如何處理邊界.這將不包括邊界,除非窗口完全適合

Not sure if it is something like this you are looking for, This is the brute-force version.and it's probably quite slow.but it does the job You have to decide what to do with the boundaries though. This will not include the boundary unless the window fits exactly

import numpy as numpy

grey_levels = 256
# Generate a test image
test_image = numpy.random.randint(0,grey_levels, size=(11,11))

# Define the window size
windowsize_r = 5
windowsize_c = 5

# Crop out the window and calculate the histogram
for r in range(0,test_image.shape[0] - windowsize_r, windowsize_r):
    for c in range(0,test_image.shape[1] - windowsize_c, windowsize_c):
        window = test_image[r:r+windowsize_r,c:c+windowsize_c]
        hist = numpy.histogram(window,bins=grey_levels)

下面是結(jié)果,完整的圖像在最后.r,c 代表窗口的左上角

Below is the result and the full image is at the end. r,c represents the topleft corner of the window

r=0,c=0
[[ 63 173 131 205 239]
 [106  37 156  48  81]
 [ 85  85 119  60 228]
 [236  79 247   1 206]
 [ 97  50 117  96 206]]

r=0,c=5
[[108 241 155 214 183]
 [202   2 236 183 225]
 [214 141   1 185 115]
 [  4 234 249  95  67]
 [232 217 116 211  24]]

r=5,c=0
[[179 155  41  47 190]
 [159  69 211  41  92]
 [ 64 184 187 104 245]
 [190 199  71 228 166]
 [117  56  92   5 186]]

r=5,c=5
[[ 68   6  69  63 242]
 [213 133 139  59  44]
 [236  69 148 196 215]
 [ 41 228 198 115 107]
 [109 236 191  48  53]]

[[ 63 173 131 205 239 108 241 155 214 183  42]
 [106  37 156  48  81 202   2 236 183 225   4]
 [ 85  85 119  60 228 214 141   1 185 115  80]
 [236  79 247   1 206   4 234 249  95  67 203]
 [ 97  50 117  96 206 232 217 116 211  24 242]
 [179 155  41  47 190  68   6  69  63 242 162]
 [159  69 211  41  92 213 133 139  59  44 196]
 [ 64 184 187 104 245 236  69 148 196 215  91]
 [190 199  71 228 166  41 228 198 115 107  82]
 [117  56  92   5 186 109 236 191  48  53  65]
 [177 170 114 163 101  54  80  25 112  35  85]]

這篇關(guān)于在 python 中將圖像劃分為 5x5 塊并計(jì)算每個(gè)塊的直方圖的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個(gè)矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測(cè)和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個(gè)矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測(cè)圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測(cè)圖像中矩形的中心和角度)
主站蜘蛛池模板: 成人亚洲精品久久久久软件 | 精品国产31久久久久久 | 欧美成人一区二免费视频软件 | 欧美黄色一区 | 日韩免费一区二区 | 嫩草国产 | 日韩欧美国产精品一区 | 国产九九九九 | 国产高清一区 | 欧美精品久久久 | 日本激情视频在线播放 | 成人精品一区二区三区 | 欧美成人aaa级毛片在线视频 | 国产精品视频在线观看 | 久久国产精品久久久久久 | 观看毛片 | 成人亚洲在线 | 亚洲第一成年免费网站 | 日本精品国产 | 九九热在线视频免费观看 | 91成人在线 | 在线视频日韩 | 曰批视频在线观看 | 亚洲先锋影音 | 久久久久久亚洲欧洲 | 久久精品成人热国产成 | 99久久国产综合精品麻豆 | 国产精品成人一区二区三区 | 国产第1页 | 天堂在线免费视频 | 日韩视频在线一区 | 99精品视频在线 | 亚洲精品99久久久久久 | 日本大香伊一区二区三区 | 国产精品成人在线观看 | 成人在线免费观看 | 久久久久久久一区二区三区 | 久久国产精品-国产精品 | 国产精品无码永久免费888 | 一呦二呦三呦国产精品 | 色视频在线播放 |