-2

I would like to compare videos. To compare the quality (Non blurry) by coding a C program. Someone told me to learn about DFT (Discrete Fourier Transform) for image analysis and to use a FFT or DFT tool to learn the difference between blurred vs detailed (non-blurry) copies of same image.

(copied from other question):
Lets say we have different files with different video quality, one is extremely clear, other is blurred, one is having rough colors. Compare all files basically frame by frame and report to the user which has better quality.

So can anyone help me with this ??

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
Meganathan
  • 21
  • 5
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow – James Z Oct 07 '18 at 14:52
  • Instead of waiting for someone to suggest a link, you could've just typed `DFT algorithm C` in Google search and got [some results to learn from](https://www.google.co.uk/search?safe=strict&source=hp&ei=du29W7fHDezOrgTYhIqoAw&q=dft+algorithm+c). If I have to Google it for you (basic), will you know what to do with it (complicated)? – VC.One Oct 10 '18 at 12:20
  • PS: Instead of DFT, I've added alternative methods in an Answer below... Let me now if these ideas help you. It would also help volunteers if you showed some example frames of your test. Then advice can be more specific to your problem. – VC.One Oct 10 '18 at 14:25

1 Answers1

2

Let's say we have various files having different video quality:

  • one is extremely clear, other is blurred, one is having rough colors.

Compare all files basically frame by frame and report to the user which has better quality.

(1) Color Quality detection...

To check which has better color, you analyze the histograms of the test images. The histogram will be a count of how many pixels have intensity X. Where X is a number ranging between 0 up to 255 (because each red, green and blue channels each holds any of those 256 possible intensities).

There are many tutorials online about how to create a histogram since it's a basic task in computer graphics.

Generally it goes like:

  • First make 3 arrays (eg: hist_Red) to hold data for red, green and blue channels.

  • Break up (using FOR loop) each pixel into individual R/G/B channel components:

example:

temp_Red = this_pixel >> 16 & 0x0ff; 
temp_Grn = this_pixel >> 8 & 0x0ff;
temp_Blu = this_pixel >> 0 & 0x0ff;
  • Then add +1 to that specific red/green/blue intensity in relevant histogram.

example:

hist_Red[ temp_Red ] += 1;
hist_Grn[ temp_Grn ] += 1;
hist_Blu[ temp_Blu ] += 1;

By adding the totals of red, green and blue, you will have total intensities of RGB in an array that could build charts like below. Check with image's array has most values to find image with better quality of colors:

(2) Detailed vs Blurred detection...

You can try using a convolution filter to detect blur in image. Give the filter a kernel (eg: a matrix). The matrix (3x3) shown below gives an edge-detect filter, where blurred images give less edges (therefore gives more black pixels).

Use logic to assume that: more black pixels EQuals a more blurred image (less detail).

You can read about convolutions here

VC.One
  • 14,790
  • 4
  • 25
  • 57