функция imshow в Pyrtools выдает разные и отрицательные диапазоны
подробности:
я следую руководству по адресу https://pyrtools.readthedocs.io/en/late ... tools.html
так как у меня нет .pgm изображение, я использую изображение в формате .jpg ниже.
вот модифицированный код Python
Код: Выделить всё
import matplotlib.pyplot as plt
import pyrtools as pt
import numpy as np
import cv2
# Load the JPG image
oim = cv2.imread('/content/ein.jpg')
print(f"input image shape: {oim.shape}")
# Convert to grayscale if it's an RGB image
if len(oim.shape) == 3: # Check if the image has 3 channels (RGB)
oim_gray = cv2.cvtColor(oim, cv2.COLOR_BGR2GRAY)
else:
oim_gray = oim # Already grayscale
print(f"grayscale image shape: {oim_gray.shape}")
# Check the range of the oim_gray
print(f"value range of oim_gray: {np.min(oim_gray), np.max(oim_gray)}")
# Subsampling
imSubSample = 1
im = pt.blurDn(oim_gray, n_levels=imSubSample, filt='qmf9')
# Check the range of the subsampled image
print(f"value range of im: {np.min(im), np.max(im)}")
# Display the original and subsampled images
pt.imshow([oim_gray, im], title=['original (grayscale)', 'subsampled'], vrange='auto2', col_wrap=2);
Код: Выделить всё
input image shape: (256, 256, 3)
grayscale image shape: (256, 256)
value range of oim_gray: (4, 245)
value range of im: (5.43152380173187, 251.90158197570906)

как видно из распечаток, оба изображения oim_gray и im находятся в положительном диапазоне. ни в im, ни в oim_gray нет отрицательных значений.
но при проверке выходного изображения я вижу диапазон -38 и 170 (пожалуйста, проверьте текст на выходном изображении). это не имеет никакого смысла, и я не понимаю. можете ли вы помочь это понять?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -np-min-an
Мобильная версия