{"id":292,"date":"2015-06-29T18:25:52","date_gmt":"2015-06-29T17:25:52","guid":{"rendered":"http:\/\/www.compucara.ie\/articles\/?page_id=292"},"modified":"2015-06-29T18:25:52","modified_gmt":"2015-06-29T17:25:52","slug":"video-quality-metrics-psnr-v-ssim","status":"publish","type":"page","link":"https:\/\/www.compucara.ie\/articles\/?page_id=292","title":{"rendered":"Video Quality Metrics PSNR v SSIM"},"content":{"rendered":"<p><strong>\u00a0Video Quality Metrics<\/strong><\/p>\n<p>Digital images are subject to a wide variety of distortions during acquisition, compression storage, transmission and reproduction.\u00a0 Any of these may result in degradation of the image quality.\u00a0 To ensure an acceptable level of quality control, video metrics are applied to judge the quality of the image.\u00a0 Ideally the image quality assessment process would supply image quality metrics that would predict the image quality automatically.\u00a0 In reality subjective tests are carried out which require human experts to view the video and assess it for quality applying the Mean Opinion Score(MOS) weighting.\u00a0 This is time consuming and expensive.\u00a0 Objective tests can be carried out automatically, these objective quality metric systems predict visual quality by using information known about the human visual system to compare signals.<\/p>\n<p>This essay will compare the performance of PSNR and SSIM &#8211; two objective video quality metrics.\u00a0 For this purpose two video clips will be employed, the video clips will be compressed using the MPEG-4 codec to 128Kbps output rate and to 1Mbps output rate, which are suitable for low speed and high speed internet connections respectively.<\/p>\n<p>Ffmpeg a computer programme which can record, convert and stream audio visual content in many formats was used to convert the files to mp4.\u00a0 The command line is as follows:<\/p>\n<p>ffmpeg \u2013i coastguard_cif.avi \u2013vcodec MPEG4\u00a0 &#8211; b 1Mb \u2013 bf 1 \u2013an \u2013psnr \u2013vstats coastbig.mp4<\/p>\n<p>-i filename, -vcodec: the codec to be used, -b: the output bit rate, -bf: the number of B frames to be included between the P frames, -an: specifies no audio, -vstats the production of statistics,\u00a0 -psnr include the psnr details.<\/p>\n<p>MSU video quality measurement tool version 2.0 was the programme used to produce SSIM information.<strong><br \/>\n<\/strong>The following tables detail information on the two video clips, information is included for the original clips and the output from the two MPEG-4 compressions performed for each.<\/p>\n<p><strong>Coastguard.avi<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"102\"><strong>\u00a0<\/strong><\/td>\n<td width=\"127\"><strong>Original file<\/strong><\/p>\n<p><strong>Coastguard_cif.avi<\/strong><\/td>\n<td width=\"129\"><strong>Compressed with Mpeg-4 for Internet slow\u00a0 connection <\/strong><\/td>\n<td width=\"120\"><strong>Compressed with MPEG-4 for Internet fast connection<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>File Size<\/strong><\/td>\n<td width=\"127\">45.6 Mbytes<\/td>\n<td width=\"129\">351Kbps<\/td>\n<td width=\"120\">1.506MBps<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Frame size<\/strong><\/td>\n<td width=\"127\">352 x 288<\/td>\n<td width=\"129\">352 x 288<\/td>\n<td width=\"120\">352 x 288<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Bit rate <\/strong><\/td>\n<td width=\"127\">30421Kbps<\/td>\n<td width=\"129\">145Kbps<\/td>\n<td width=\"120\">914Kbps<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Frame rate<\/strong><\/td>\n<td width=\"127\">25 fps<\/td>\n<td width=\"129\">25 fps<\/td>\n<td width=\"120\">25 fps<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Length<\/strong><\/td>\n<td width=\"127\">12 secs<\/td>\n<td width=\"129\">12 secs<\/td>\n<td width=\"120\">12 secs<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Compression factor <\/strong><\/td>\n<td width=\"127\"><\/td>\n<td width=\"129\">125<\/td>\n<td width=\"120\">29<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Frame size<\/strong><\/td>\n<td width=\"127\">152105 bytes<\/td>\n<td width=\"129\">72 \u2013 27018bytes<\/td>\n<td width=\"120\">113 -27018 bytes<\/td>\n<\/tr>\n<tr>\n<td width=\"102\"><strong>Recognition<\/strong><\/td>\n<td width=\"127\"><\/td>\n<td width=\"129\">Significant blocking, particularly when there is activity in the scene<\/td>\n<td width=\"120\">Very little variance from original<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>News.avi file<\/strong><\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"104\"><strong>\u00a0<\/strong><\/td>\n<td width=\"127\"><strong>Original file<\/strong><\/p>\n<p><strong>news_cif.avi<\/strong><\/td>\n<td width=\"129\"><strong>Compressed with Mpeg-4 for Internet slow\u00a0 connection <\/strong><\/td>\n<td width=\"133\"><strong>Compressed with MPEG-4 for Internet fast connection<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>File Size<\/strong><\/td>\n<td width=\"127\">45.6 MB<\/td>\n<td width=\"129\">339KB<\/td>\n<td width=\"133\">1.532MB<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Frame size<\/strong><\/td>\n<td width=\"127\">352 x 288<\/td>\n<td width=\"129\">352 x 288<\/td>\n<td width=\"133\">352 x 288<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Bit rate <\/strong><\/td>\n<td width=\"127\">30421Kbps<\/td>\n<td width=\"129\">197Kbps<\/td>\n<td width=\"133\">1007Kbps<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Frame rate<\/strong><\/td>\n<td width=\"127\">25 fps<\/td>\n<td width=\"129\">25 fps<\/td>\n<td width=\"133\">25 fps<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Length<\/strong><\/td>\n<td width=\"127\">12 secs<\/td>\n<td width=\"129\">12 secs<\/td>\n<td width=\"133\">12 secs<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Compression factor <\/strong><\/td>\n<td width=\"127\">1<\/td>\n<td width=\"129\">130<\/td>\n<td width=\"133\">29<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Frame size<\/strong><\/td>\n<td width=\"127\">152105bytes<\/td>\n<td width=\"129\">43 -12970 bytes<\/td>\n<td width=\"133\">166-24865bytes<\/td>\n<\/tr>\n<tr>\n<td width=\"104\"><strong>Recognition<\/strong><\/td>\n<td width=\"127\"><\/td>\n<td width=\"129\">Significant blocking, particularly when there is activity dancers<\/td>\n<td width=\"133\">Very little variance from original<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Peak signal to noise ratio (PSNR is frequently used as a measure of the distortion introduced by MPEG compression.\u00a0 For colour video, it is typically acceptable to compute PSNR on the luminance component only.\u00a0 However, PSNR is not based on signal difference as processed by the human visual system. \u00a0Typical PSNR values for lossy compression are between 30 and 50db, the higher the value the better the quality.<\/p>\n<p>The actual metric that is in use in this part of the assignment is the peak signal-to-reconstructed image measure which is called PSNR.\u00a0 The MOS refers to the Mean Opinion Score to describe the subjective viewing comparison.\u00a0 The following is a brief comment on each video clip regarding the subjective and objective quality measures.<\/p>\n<p><strong>Coastguard output at quality of 128Kbps<\/strong><\/p>\n<p>The maximum value of PSNR in this sequence is 41.41 and the minimum is 25.19 with an average of 27.35.\u00a0 On subjective analysis of the clip, significant blocking takes place (MOS = 1) between frames 25 and 80. In this section of the film clip there is a scene in which two boats are in motion and this, in turn, causes \u00a0movement in the water. However, this is not reflected in the PSNR(figure 1)\u00a0 whose value in these frames does not\u00a0 fall below 32, which is well above average for the clip.<\/p>\n<p>&nbsp;<\/p>\n<p>The SSIM (Figure 2) \u00a0values for this clip range from a minimum of .21164 to a maximum of .96969 \u00a0with an average value of .649144 over the 300 frames. The SSIM\u00a0 has its lowest values in the frames 50 to 80 which coincides with the part of the clip where the two boats are moving on the water\u00a0 the SSIM graph output clearly indicates that there is a significant issue with quality at this point in the video with some of the frames in this range labelled as bad frames.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Figure 4: SSIM for coastguard.avi compressed using MPEG-4 to output rate of 1Mbps<\/strong><\/p>\n<p><strong>Coastguard output at 1Mbps<\/strong><\/p>\n<p>The maximum value of PSNR in this sequence is 41.43 and the minimum is 31.5 with an average of 34.43.\u00a0 This higher PSNR average demonstrates the superior quality of the output at these compression settings.\u00a0 Whereas the highly compressed video mentioned above has a greater range between the maximum and the minimum PSNR, the difference is not so great in this, with the minimum well above the average in the previous clip. In this case, the PSNR results correlate with \u00a0the subjective measure with MOS not lower than 4 at any point.<\/p>\n<p><strong>Figure 6: SSIM for news.avi compressed using MPEG-4 to output rate of 128Kbps<\/strong><\/p>\n<p><strong>Figure 8: SSIM for news.avi compressed using MPEG-4 to output rate of 1Mbps<\/strong><\/p>\n<p><strong>News output at 1Mbps<\/strong><\/p>\n<p>The maximum value of PSNR in this sequence is 45.25 and the minimum is 39.87 with an average of 43.89.\u00a0 This small range of values reflects the high quality result of this compression with little or no interruption to the viewer with a MOS of 5.\u00a0\u00a0 The SSIM values for this clip range from a minimum of .83389 to a maximum of .98662 with an average value of .956755 over the 299 frames.\u00a0 The SSIM values display a dip in three areas as mentioned previously (frames 89,148,239), as SSIM incorporates structural information, luminance and contrast information the changing of a large part of the background from dark to light will register as a significant difference to the SSIM model, whereas subjectively this would not register as a change in the background is perceived to be a normal event.<\/p>\n<p><strong>Group of Pictures<\/strong><\/p>\n<p>Each sequence of is subdivided into groups of pictures and the groups of pictures are subdivided into slices or frames, each slice will be of type I, P, B or D.\u00a0 I frames are Intra frames and as are compressed soley in a spatial manner they will have a higher PSNR value and SSIM, P frames are predicted and will have a lower value for PSNR and SSIM and B frames are bi-directionally predicted they will have the lowest value for PSNR and SSIM.\u00a0 Each GOP starts with an I frame , the periodic peaks on the graph represent the I-frames, counting the frames between the peaks gives a GOP of between 10 and 15 frames.\u00a0 The GOP length is constant for the file, and in this instance the GOP length is the approximately the same for every clip.\u00a0 This is contrary to good practice as for the best performance, at low bit rate streaming, the visual quality of the output can be considerably improved by reducing the frame rate and the GOP size.<\/p>\n<p>The relationship between increased compression levels and reduced PSNR is demonstrated in figure 10, the frames of the output produced by compressing to a rate of 128Kbps in the main has all frames compressed above 95:1, with all frames compressed above 90:1and the majority of teh PSNR values are in the range 25 to 35 with equivalent MOS values of poor to good, whereas the 1Mbps output has a more diverse range of compression ratio form 80:1 to 98:1 and has the PSNR values in the range 32 to 43 with MOS values of good to excellent.<\/p>\n<p><strong>Figure 12: PSNR vs compression ratio for news.avi compressed using MPEG-4 <\/strong><\/p>\n<p>The PSNR values for news.avi compressed to 1Mbps are contained within a small range of 42 to 45, where as the compression ratio is spread over 82: to 99.9:1, the type of video lent itself well to compression, with the majority of the contents of the frame staying constant from frame to frame.\u00a0 The compression rate for the majority of frames in the clip compressed at 128Kbps is in the region of 99:1 with only the I frames compressed at a lower rate(90:1-96:1) as evidenced by Figure 9.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0Video Quality Metrics Digital images are subject to a wide variety of distortions during acquisition, compression storage, transmission and reproduction.\u00a0 Any of these may result in degradation of the image quality.\u00a0 To ensure an acceptable level of quality control, video metrics are applied to judge the quality of the image.\u00a0 Ideally the image quality assessment&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/pages\/292"}],"collection":[{"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=292"}],"version-history":[{"count":1,"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/pages\/292\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=\/wp\/v2\/pages\/292\/revisions\/293"}],"wp:attachment":[{"href":"https:\/\/www.compucara.ie\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}