Divide an image into 5x5 blocks in python and compute histogram for each block(在 python 中将图像划分为 5x5 块并计算每个块的直方图)
问题描述
使用 Python,我必须:
Using Python, I have to:
- 将
Test_Image
和Reference_image
分成 5x5 块, - 计算每个块的直方图,并将其与另一个图像中的相同块进行比较.
例如:image1(1,1)
和image2(1,1)
. - 比较两张图片的相似度(应该是变换不变的).
- Divide a
Test_Image
andReference_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)
withimage2(1,1)
. - Compare the similarity between two images (should be transform invariant).
到目前为止,我已经使用 hist=numpy.histogram(image,bins=256)
So far, I have calculated the histogram of the whole image using hist=numpy.histogram(image,bins=256)
我想分割图像,然后计算所有这些块的直方图.我还想使用 Bhattacharya 的系数来衡量相似度.
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.
谁能指导我如何通过这个?在此先感谢:)
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
下面是结果,完整的图像在最后.r,c 代表窗口的左上角
Below is the result and the full image is at the end. r,c represents the topleft corner of the window
这篇关于在 python 中将图像划分为 5x5 块并计算每个块的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!