有没有办法使用 cv2 查找和比较两个图像中某个区域的强度?
Is there a way to find and compare the intensity of a region in two images using cv2?
我拍摄了色素沉着疤痕的前后图像,我想使用 opencv 测量改善情况。
首先,我调整了两个图像的曝光度,然后将它们转换为灰度并使用以下方法反转它们:
img = Image.open('IMG_7641.jpg').convert('LA')
img.save('greyscale.png')
im = Image.open('greyscale.png').convert('RGB')
im_invert = ImageOps.invert(im)
im_invert.save('inverted.png')
我现在想确定两幅图像中最亮区域的强度,并将其用作量化后图改进的一种方式。我已经模糊了图像,但我不确定如何获得强度值。
gray = cv2.imread('inverted.png')
blurred = cv2.GaussianBlur(gray,(5,5),0)
您可以使用 Numpy 来测量均值(平均值),或者您可以使用它来获取每个图像中的最大值。
mean = np.mean(blurred)
print('mean:', mean)
max = np.amax(blurred)
print('max:', max)
见
https://numpy.org/doc/stable/reference/generated/numpy.mean.html
https://numpy.org/doc/stable/reference/generated/numpy.amax.html
我拍摄了色素沉着疤痕的前后图像,我想使用 opencv 测量改善情况。
首先,我调整了两个图像的曝光度,然后将它们转换为灰度并使用以下方法反转它们:
img = Image.open('IMG_7641.jpg').convert('LA')
img.save('greyscale.png')
im = Image.open('greyscale.png').convert('RGB')
im_invert = ImageOps.invert(im)
im_invert.save('inverted.png')
我现在想确定两幅图像中最亮区域的强度,并将其用作量化后图改进的一种方式。我已经模糊了图像,但我不确定如何获得强度值。
gray = cv2.imread('inverted.png')
blurred = cv2.GaussianBlur(gray,(5,5),0)
您可以使用 Numpy 来测量均值(平均值),或者您可以使用它来获取每个图像中的最大值。
mean = np.mean(blurred)
print('mean:', mean)
max = np.amax(blurred)
print('max:', max)
见
https://numpy.org/doc/stable/reference/generated/numpy.mean.html https://numpy.org/doc/stable/reference/generated/numpy.amax.html