Image Processing: Temporal/Spacial Median Filter
(C) copyright December 2007, vcdhelp member, vhelp.
---------------------------------------------------------------------
FILTER: VH-TSMedian
PURPOSE: The design of this type of filter is for the removal of random noise.
And it does a fairly good job of it when the origin is from an analog type source.
INTRODUCTION:
I am very pleased to announce my exploration and experiences with video imaging and
processing which has now come to a point where I am expanding into the filter plugin
domain. So please bare with me as I try to write this article (or white paper) out for
your reading. I feel that because I am not a writer that this is very amaturish at best.
I hope to write more in the future..
After several years of researching in image processing, I am finally scratching around in the
areas of filter algorithms and have even coded up a few that deal with various images from
video captures I make of my analog sources, like laserdisc; vhs; and cabletv. But most of
these filter are still in the Alpha stages and not quite ready for prime time, yet.
The few filters I had the pleasure of developing are by no means comparitble to the many
that are already floating around the internet or included in commerical software suites.
I am mostly happy at finally being able to start working in this area, though mainly for my
own purposes.
Unfortunately, at this time, the filter being discussed in this article is not a plugin for any of
the popular video editors like Virtualdub or AVIsynth because I don't know how to write these
things in c/c++, which these two champs require. My filter(s) are developed in the Pascal
programming language. But I wanted to share my experience with you all because I was
finally able to make a breakthrough with the filter I was working/debugging and for a very
long time, and I was satisfitied that I made progress, finally. And I also had the pleasure of
giving it a name, VH.TSMedian.
Now, in my search for filter examples, (so that I could get a building block or template to
gauge by) the filter algorithms were mainly written in c/c++ or c# or even fortran. There
were virtually no filters in the Pascal language. And those that I did come across were just
too complicated for me to follow and understand. I was completely lost. So, I had decided
to just start from scratch, from the bottom up and whatever knowlege I learnt along the
way (via exhaustive google searchs) I molded into the building process using my knowledge
of the Pascal programming language. So expect to see crude results of these filter designs,
but I'm happy to share these experiences with you all.
In the next section I go into the abstract of the this filter. It describes its function in a bit
more detail. However, it is not ment to replace or duplicate those defined and outlined in
advanced white paper language.
ABSTRACT: of the VH-TSMedian filter
I should say that there are many filters designed with similar functions or purposes when
based on temporal and/or spacial domains. However, the median algorithm is mostly if
not closely the same.
The filter is based off the Temporal and Spacial domain. The algorithm works in both the
temporal and spacial areas of the images. It actually performs two algorithmic functions
at the same time during its processing of the images.
In the Temporal, the algorithm does processing across three frames, Previous; Current; and
Next frames. I denote them as p/c/n, for similicity sake. It takes in three frames and makes
attempts to determine each pixels probable value, reviewing which pixel is closest matching
to its temporal naughbor. I would like to point out that in this filter implentation, all the
pixels are factored into the median's equation. It was easier to code without using floating
point (decimal numbers) which would have complicated things a bit more. What this means
is that the center pixel was included. In some algorithms they are not -- (because the center
pixel is usually the one to be replaced) -- it all depends on the developers project perspective
and engineering approach.
And in the Spacial, the algorithm does processing also for the three frames but within a spacial
coordinate, for all of the three frames. In this part, the algorithm performs the final analysis
of the pixels within the spacial areas of the three frames and its surounding naughbor of pixels,
calculating its temporal and spacial naughbors for its pixel replacement by median.
[ ][ ][ ] . [ ][ ][ ] . [ ][ ][ ]
[ ][ ][ ] . [ ][ ][ ] . [ ][ ][ ]
[ ][ ][ ] . [ ][ ][ ] . [ ][ ][ ]
P C N
Fig 01: an illustration of temporal, using three frames, p,c and n
The Median algorithm is a simple one. I chose a simple aproach because I am a beginner in
this area and I do not need to confuse myself with complicated technique and things.
Basically, all that is done is this:
Sort an array of byte values. And from that sorted array, chose the mid point value,
(as seen in Fig 02) this is your median value. This is the value that we will use to replace
every pixel in the newf image, for every frame in the video.
Array: [10][50][90][40][15][05][04][10][12]
Median: [04][05][10][10][12][15][40][50][90]
Fig 02: example layout of initial array integer values, then sorted for median
Thus, the median value for this example is 12.
So, in the VH.TSMedian, the median values are calculated, Temporal and Spacial,
and assigned to every pixel, from left to right, top to bottom for the image to be filtered.
The p, c, and n frames are never touched. They are only used as references for the
final (median 'ized) frame, we'll call it, newf.
And every frame that is run through this filter is median assigned except for the first and last
frames, and also except for the outermost edge of the image because that is the limit of the
algorithm.
About VH.TSMedian filters result..
I have not had the time to tabulize this filters results across various source scenarios.
I was merely happy that I got it working and started writing my memoirs about it, here.
The functional purpose of this filter is to mildly reduce random noise from most analog
video sources, like laserdisc; vhs; cabletv; etc. The results of this filter has shown me
that it can be unpredictable at times. However, I was surprised to learn that it does a
decent job with interlaced video. So, more testing and debugging will need to be done
to remove or reduce these limitations.
The following images desmonstrate the VH.TSMedian results as used in a test
capture recently performed during a Thanksgiving tv special. The source was from
cabletv and channel 2-CBS, and it was quite noisy to my surprise. I don't normally
watch this channel, so it was a surprise to me to learn how noisy this channel is. I also
noticed that this channel had an issue with another noise phenomina, Haringbone, where
there is a descirnable frequency drift or pattern. I believe that the filter did help to
reduce it, some. But I'll let you decide for yourselve's.
Tomorrow [ done ], I will upload several of the actual videos that were run through this filter so
that you can get a better idea of the posted images and then you can analize the video
if you want, for flaws and other interesting things. Each of the video will prob be some
where around 35 mb in size or larger. I will look into shrinking them through winrar.
** Orignal image from ananlog cabletv capture with a Pinnacle Studio AV/DV pci card
** D/L File: http://www.megaupload.com/?d=AHNFM4TL
** VH-TSMedian Lite mode -- after
** D/L File: http://www.bestsharing.com/files/p6EiY384716/vhelp.vh.tsmedian.lite.rar.html
** VH-TSMedian HQ version -- after
** D/L File: http://www.bestsharing.com/files/7uM1s384714/vhelp.vh.tsmedian.hq.rar.html
About the images, above..
They are basically self explanitory, but the last image was from the Alpha version of
VH.TSMedian. I included a demo from this filter because it did surprising well for the
interlace when the motion was very little.
Future plans..
I feel that there are some minor problems with this filter. The filter is not quite done, and
there's still issues that need ironing out. And I would like to tune the calculating of the mean
within the temporal and spacial domain. I think that it could be better or more defined in its
purpose.
And, I made a higher quality version of this filter, and it does a really good job of stationary
scenes. But, the first sign of motion, and the artifacts come out in those movements. That
too needs to be debugged. I've tested it on various source, inlcuding vhs, and I was very
happy at the results. So, if I can fix the issues with motion, it will be my greatest filter yet.
My hopes and intentions of filter development is to incorporate into video restoration processes.
And last, I haven't decided if this article is complete. I may revise it or add/remove various
things from it.
From the Video Workstation of,
-vhelp 4480
:P *~*!*~*!~* HaPpY HoLiDaYs *~*!*~*!~*
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 5 of 5
Thread
-
-
Looks really good, vhelp. I'm looking forward to seeing the video clips.
-
Thanks Soopafresh. I was in a hurry, posting this message and then the pics. I was
trying to get it in before the 24th, but it was just too agonizing over dial-up
After looking at and re-reading, I found a few typos. Don't you hate that ? Anyways.
And I came to realize that I'd like to include samples from vhs also, because that is the
source I deal with mostly, and in EP mode recordings, these days. So I want to do what-
ever I can to clean or help reduce most of the noise, and this filter (when in HQ mode) did
do a respectable job. But the Lite version did well, too. VH.TSMedian doesn't over
smooth like your tradition Convolution filters do. It only mildly touches the video, and
leaving most of the detail in tact.
You know.., I tried a version of Spacial only. And, although it worked as expected, I did
not like the image. It remined me of the Convolution3D filter -- both for Virtualdub and
AVIsynth -- where the image becomes plastic'y or blotchy from the machanics of the
Spacial's charactoristics, when used alone in a spacial domain. And that is why (IMHO)
a filter implementation should include a temporal domain in its design, because less detail
is removed and more of the original image stands out.
But, I really want to get the HQ mode working. It needs lots of debugging. So, I might
be out of commision for a while in order to really give it my fullest attention. That's why
you haven't seen me around here, lately -- too busy.
I forgot to mention, that if I can manage the filters complete'ness, I would like to include
a working stand alone tool, though prob command line or gui. I don't know yet.. I'm jump-
ing the gun here, now.
Thanks again for the complements, and until then..
-vhelp 4481
:P *~*!*~*!~* HaPpY HoLiDaYs *~*!*~*!~* -
Hi everyone.
I have uploaded all the demo clips. See the original post above with pics for links.
** Original ----- from a Pinnacle Studio AV/DV pci capture card and analog cable tv
** Lite verion -- the clean and working version
** HQ version; - not so good in motion scenes.. needs more work.. could be the one.
Thanks, and Merry Christmas,
From the Video Workstation of,
-vhelp 4482
:P *~*!*~*!~* HaPpY HoLiDaYs *~*!*~*!~* -
What ever happened to this?
Did you perhaps turn it into a workable program, plugin or filter for something?
Interlaced-domain median filters are more or less non-existent, it seems.Want my help? Ask here! (not via PM!)
FAQs: Best Blank Discs • Best TBCs • Best VCRs for capture • Restore VHS
Similar Threads
-
How to keep ffdshow post processing(deblocking filter) in finalized video
By Milardo in forum EditingReplies: 6Last Post: 5th Apr 2011, 06:09 -
ffvdub or ffdshow encoder image processing doesn't work with VirtualDub?
By Milardo in forum EditingReplies: 42Last Post: 21st Jan 2011, 19:09 -
Which is the best VDub filter to fix this video/image?
By zanos in forum RestorationReplies: 7Last Post: 12th Feb 2009, 17:37 -
Which one directshow filter to resize the image ?
By jazzzy in forum Software PlayingReplies: 1Last Post: 20th Feb 2008, 10:55 -
Best image quality as possible for AVI videos...FFdshow filter.Any ideas???
By fgtan in forum Media Center PC / MediaCentersReplies: 0Last Post: 21st Jun 2007, 15:17