While the final arbiter of image quality is the human viewer, efforts have been made to create objective measures of quality. This can be useful for many applications. Many objective measures of quality require the existence of a distortion-free copy of an image, called the reference image, that can be used for comparison with the image whose quality is to be measured. The dimensions of the reference image matrix and the dimensions of the degraded image matrix must be identical.
The Image Processing Toolbox provides several function that can be used to measure quality:
psnr
— The peak signal-to-noise ratio measure of
quality works by first calculating the mean squared error (MSE) and then
dividing the maximum range of the data type by the MSE. This measure is
simple to calculate but sometimes doesn't align well with perceived
quality by humans.
ssim
— The Structural Similarity (SSIM) Index measure
of quality works by measuring the structural similarity that compares
local patterns of pixel intensities that have been normalized for
luminance and contrast. This quality metric is based on the principle
that the human visual system is good for extracting information based on
structure.
Obtain Local Structural Similarity Index
Compare Image Quality at Various Compression Levels
This example shows how to measure the quality of regions of an image when compared with a reference image. The ssim
function calculates the structural similarity index for each pixel in
an image, based on its relationship to other pixels in an 11-by-11
neighborhood. The function returns this information in an image that is
the same size as the image whose quality is being measured. This local,
pixel-by-pixel, quality index can be viewed as an image, with proper
scaling.
Read an image to use as the reference image.
ref = imread('pout.tif');
Create an image whose quality is to be measured, by making a copy of the reference image and adding noise. To illustrate local similarity, isolate the noise to half of the image. Display the reference image and the noisy image side-by-side.
A = ref; A(:,ceil(end/2):end) = imnoise(ref(:,ceil(end/2):end),'salt & pepper', 0.1); figure, imshowpair(A,ref,'montage')
Calculate the local Structural Similarity Index for the modified image (A), when compared to the reference image (ref). Visualize the local structural similarity index. Note how left side of the image, which is identical to the reference image displays as white because all the local structural similarity values are 1.
[global_sim local_sim] = ssim(A,ref); figure, imshow(local_sim,[])
This example shows how to test image quality using ssim
.
The example creates images at various compression levels and then plots
the quality metrics. To run this example, you must have write permission
in your current folder.
Read image.
I = imread('cameraman.tif');
Write the image to a file using various quality values. The JPEG format supports the ‘Quality'
parameter. Use ssim
to check the quality of each written image.
ssimValues = zeros(1,10); qualityFactor = 10:10:100; for i = 1:10 imwrite(I,'compressedImage.jpg','jpg','quality',qualityFactor(i)); ssimValues(i) = ssim(imread('compressedImage.jpg'),I); end
Plot the results. Note how the image quality score improves as you increase the quality value specified with imwrite
.
plot(qualityFactor,ssimValues,'b-o'); xlabel('Compression Quality Factor'); ylabel('SSIM Value');
About Us Contact Us Focus on Color Global Agents Site Map
Link:colorimeter Color Assessment Cabinets pecolor iQstest spectrophotometer
© 1998~2024 ColorController, Incorporated. All Rights Reserved.