piq
piq copied to clipboard
Metric: MAD
Is your feature request related to a problem? Please describe. Most Apparent Distortion algorithm combines two measures depending on image quality, based on observance of how HVS works:
- HI index: Local luminance and contrast masking are used to estimate detection-based perceived distortion in high-quality images
- LO index : changes in the local statistics of spatial-frequency components are used to estimate appearance-based perceived distortion in low-quality images. When judging the quality of an image containing visible distortions, one tends to rely much less on visual detection and much more on overall image appearance Performances : Although it doesn't perform so well according to papers of IW-SSIM and GSMD, it does ok in papers of DSS, HaarPSI, and in the two following papers :
- 2D and 3D Image Quality Assessment: A Survey of Metrics and Challenges, 2009
- A Comparative Study of Image Quality Assessment Models through Perceptual Optimization, 2020
Describe the solution you'd like Implement metric in Pytorch
Describe alternatives you've considered I'm not so knowledgeable in Pytorch, but if you don't have time I can try taking care of this implementation based on the below Pytorch code
Additional context Original paper : https://s2.smu.edu/~eclarson/pubs/2010JEI_MAD.pdf Author matlab code (newest version): http://vision.eng.shizuoka.ac.jp/mad/MAD_index_2011_10_07.zip Pytorch code : https://github.com/dingkeyan93/IQA-optimization/blob/master/IQA_pytorch/MAD.py
I tested the pytorch code. It is pretty similar to the matlab code except that they do not "kill the edges" at the end of index calculations, but I did not verify the parts that were originally C code in the authors zip (ical_stat, ica_sdt, get_moments
...). The code works fine and can be called this way on GPU:
from mad import prepare_image, MAD
# img_1, img_2 rgb image in [0-255]
reference = prepare_image(img_1, repeatNum = 1).to(device)
degraded = prepare_image(img_2, repeatNum = 1).to(device)
model = MAD(channels=1).to(device)
return model(reference, degraded, as_loss=False).item()
where prepare_image is this code:
def prepare_image(image, resize = False, repeatNum = 1):
if resize and min(image.size)>256:
image = transforms.functional.resize(image,256)
image = transforms.ToTensor()(image)
return image.unsqueeze(0).repeat(repeatNum,1,1,1)
Hi @leihuayi Same question here. If you didn't start working on MAD I'll assign it to another student 😄
I want to take this issue
Hi @zakajd I hadn't planned to work on this implementation since I had put a link of a pytorch version to copy from on the description: https://github.com/dingkeyan93/IQA-optimization/blob/master/IQA_pytorch/MAD.py
@Shamus98 you are welcome to work on it ^^