pbristow
14th April 2010, 19:35
Hi!
Prompted by the recent discussions about converting anaglyph images to other formats, I've been experimenting with the use of MVTools to synthesize the missing colour data for each eye of a Blue/Yellow anaglyph video (Blue/Yellow? Yeah, it's crazy, but that's how they did it! Nearly all the image info is on the yellow side, natch...)
Anyway, I've found that some problems occur due to Manalyse mistakenly assigning vectors well away from the horizontal. Since the images I've got are well aligned vertically, I just need to force MAnalyse to only search along the x-axis, and ignore the y-axis. (This should also speed up the MAnalyse pass quite a lot! :) )
While I'm at it, for another use I've got in mind, it would be handy to have a vertical-only search too (for detecting and fixing vertical jitter on bad VHS rips).
So I've taken the plunge and looked at the sources for MVTools, and here's what I think I need to add:
1. In MVAnalyse.cpp, in the switch(st) block of code, add the following cases:
case 6 :
searchType = HORIZONTAL;
nSearchParam = ( stp < 1 ) ? 1 : stp;
break;
case 7 :
searchType = VERTICAL;
nSearchParam = ( stp < 1 ) ? 1 : stp;
break;
2. In PlaneOfBlocks.cpp,
//After:
if ( searchType & UMHSEARCH )
UMHSearch(nSearchParam, bestMV.x, bestMV.y);
//Insert:
if ( searchType & HORIZONTAL )
HorizontalSearch();
if ( searchType & VERTICAL )
HorizontalSearch();
and
//After:
if ( searchType & UMHSEARCH )
UMHSearch(nSearchParam, bestMV.x, bestMV.y);
//Add:
if ( searchType & HORIZONTAL )
HorizontalSearch();
if ( searchType & VERTICAL )
HorizontalSearch();
And finally:
//After the big chunk of code that goes:
void PlaneOfBlocks::UMHSearch(int i_me_range, int omx, int omy) // radius
{
*** LOADS OF STUFF HERE ***
}
//Add:
void PlaneOfBlocks::HorizontalSearch(int r, int s, int mvx, int mvy) // width = 2*r + 1, step=s
{
// Examine a horizontal line working outward from (mvx, mvy)
int i;
// work along a line from -r to +r
for ( i = 1; i < r; i+=s ) //
{
CheckMV(mvx + i, mvy);
CheckMV(mvx - i, mvy);
}
}
void PlaneOfBlocks::VerticalSearch(int r, int s, int mvx, int mvy) // width = 2*r + 1, step=s
{
// Examine a horizontal line working outward from (mvx, mvy)
int i;
// work along a line from -r to +r
for ( i = 1; i < r; i+=s ) //
{
CheckMV(mvx, mvy+ i);
CheckMV(mvx, mvy+ i);
}
}
Now the obvious thing for me to do is to throw this code into a scratch copy of the source files and run a build and find out what I've missed. Only... I don't have a working compiler here at present. Is there any kind soul interested enough in this run an experienced eye over my code, and run me a test build?
And would folks be interested in seeing these two search types added to MVTools2?
Prompted by the recent discussions about converting anaglyph images to other formats, I've been experimenting with the use of MVTools to synthesize the missing colour data for each eye of a Blue/Yellow anaglyph video (Blue/Yellow? Yeah, it's crazy, but that's how they did it! Nearly all the image info is on the yellow side, natch...)
Anyway, I've found that some problems occur due to Manalyse mistakenly assigning vectors well away from the horizontal. Since the images I've got are well aligned vertically, I just need to force MAnalyse to only search along the x-axis, and ignore the y-axis. (This should also speed up the MAnalyse pass quite a lot! :) )
While I'm at it, for another use I've got in mind, it would be handy to have a vertical-only search too (for detecting and fixing vertical jitter on bad VHS rips).
So I've taken the plunge and looked at the sources for MVTools, and here's what I think I need to add:
1. In MVAnalyse.cpp, in the switch(st) block of code, add the following cases:
case 6 :
searchType = HORIZONTAL;
nSearchParam = ( stp < 1 ) ? 1 : stp;
break;
case 7 :
searchType = VERTICAL;
nSearchParam = ( stp < 1 ) ? 1 : stp;
break;
2. In PlaneOfBlocks.cpp,
//After:
if ( searchType & UMHSEARCH )
UMHSearch(nSearchParam, bestMV.x, bestMV.y);
//Insert:
if ( searchType & HORIZONTAL )
HorizontalSearch();
if ( searchType & VERTICAL )
HorizontalSearch();
and
//After:
if ( searchType & UMHSEARCH )
UMHSearch(nSearchParam, bestMV.x, bestMV.y);
//Add:
if ( searchType & HORIZONTAL )
HorizontalSearch();
if ( searchType & VERTICAL )
HorizontalSearch();
And finally:
//After the big chunk of code that goes:
void PlaneOfBlocks::UMHSearch(int i_me_range, int omx, int omy) // radius
{
*** LOADS OF STUFF HERE ***
}
//Add:
void PlaneOfBlocks::HorizontalSearch(int r, int s, int mvx, int mvy) // width = 2*r + 1, step=s
{
// Examine a horizontal line working outward from (mvx, mvy)
int i;
// work along a line from -r to +r
for ( i = 1; i < r; i+=s ) //
{
CheckMV(mvx + i, mvy);
CheckMV(mvx - i, mvy);
}
}
void PlaneOfBlocks::VerticalSearch(int r, int s, int mvx, int mvy) // width = 2*r + 1, step=s
{
// Examine a horizontal line working outward from (mvx, mvy)
int i;
// work along a line from -r to +r
for ( i = 1; i < r; i+=s ) //
{
CheckMV(mvx, mvy+ i);
CheckMV(mvx, mvy+ i);
}
}
Now the obvious thing for me to do is to throw this code into a scratch copy of the source files and run a build and find out what I've missed. Only... I don't have a working compiler here at present. Is there any kind soul interested enough in this run an experienced eye over my code, and run me a test build?
And would folks be interested in seeing these two search types added to MVTools2?