quick problem description:
pyrtools imshow function giving me different and negative ranges
details:
im following the tutorial at https://pyrtools.readthedocs.io/en/latest/tutorials/01_tools.html
since i dont have .pgm image, i'm using the below .jpg image.
here is the modified python code
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);
and here is the output
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)
with the given image
as you can see, from the printouts, both the images oim_gray and im are in positive range. there aren't any negative values on neither im and oim_gray.
but when checking the output image, i see the range -38 & 170 (please check the text over the output image). this doesn't make any sense, and don't understand. can you help on this to understand?
That is behavior of pyrtools
, specifically decided by vrange='auto2'
.
'auto2'
: all images have same vmin/vmax, which are the mean (across all images) minus/plus 2 std dev (across all images)
If you don't like that library's behavior, you can file a bug at https://github.com/LabForComputationalVision/pyrtools/issues