Traditional Culture Encyclopedia - Traditional culture - Urgent Request! Image Matching Algorithm Code
Urgent Request! Image Matching Algorithm Code
procedure ImageMatching
{
Input FirstImage;
Input SecondImage;
//Get the size of the two images
Height1= GetImageHeight(FirstImage);
Height2=GetImageHeight(SecondImage);
Width1=GetImageWidth(FirstImage);
Width2= GetImageWidth(SecondImage);
/// Take the grid matching template from the second image
SecondImageGrid = GetSecondImageGrid(SecondImage);
/// Roughly matching, the grid moves from the left to the right first image, then from the bottom to the bottom of the first image. left to right, then bottom to top, one grid spacing at a time, Step_Width or Step_Height, ends when the grid moves out of the overlap area
y=Heitht1-GridHeight;
MinValue = MaxInteger;
While ( y& lt;Height1-OverlapNumber)//End when the grid moves out of the overlap
{
x=Grid_Width/2; //The horizontal coordinate of point A when the grid is at the far left of the first image.
While ( x<(Width1-Grid_Width/2) )
{
FirstImageGrid=GetImgaeGrid(FirstImgaeGrid, x, y);
differ=CaculateDiff( FirstImgaeGrid, SecondImageGrid);//calculate the flat of the pixel value difference
//square sum
if (differ<MinValue)
{
BestMatch_x=x;
BestMatch_y= y;
MinValue = differ;
}
x= x+Step_width;
}
y=y-Step_Height;
}
Step_Width= Step_ Width/2;
Step_Height= Step_Height/2;
While ( Step_Height>0 & Step_Width>0)//End when both horizontal and vertical steps are reduced to zero
{
if( Step_Height==0)//Set to 1 when only vertical steps are decremented to zero
Step_Height=1;
If(Step_Width==0) //Set to 1 when only horizontal steps are decremented to zero
Step_Width=1;
temp_ x = BestMatch_x;
temp_y = BestMatch_y;
for ( i= -1; i<1; i++)
for( j= -1; j<1; j++)
{
if ((i=0&j!=0)|(i! =0&j=0))
{
FirstImageGrid=GetImgaeGrid(FirstImgaeGrid,
temp_x+i*Step_Width, temp_y +j*Step_Height);
differ=CaculateDiff(FirstImgaeGrid, SecondImageGrid);
if (differ<MinValue)
{
BestMatch_x=x;
BestMatch_y=y ;
MinValue = differ;
}
}
}
Step_Height = Step_Height /2;
Step_Width = Step_Width/2;
}
}
}
} p>
Ask me if you don't understand and talk to each other
- Previous article:Starbucks seeks English for all kinds of coffee.
- Next article:How about learning java? Is it easy to find a job?
- Related articles
- What is the difference between black tea and green tea production process
- The custom of "not shaving your head in the first month" has a long history. Why do you say that?
- Proverbs about old customs.
- Digital RMB payment method
- The experience of elementary school students in the national classics:The experience of learning the national classics
- Species of marine fish
- How do college entrance examination students cope with traditional cultural problems
- The Difference between Dm7 Chord and d7 Chord (Piano)
- Chrysanthemum cuttings time and method video tutorials
- Dance opening speech