Multi-Object Recognition
Ideas
1. Mark the image first. Give each target a label.
2. Calculate the NMI feature values of each labeled target,
3. Then these NMI feature values are compared with the known NMI feature values to be identified.
If the difference value is smaller than a threshold value, it indicates that the target is the target to be identified.
Bool cbiaoji1: objectionextrationnmi (iplimage * SRC)
{
DWORD T3, T4; bool status = false;
T3 =: gettickcount ();
Iplimage * imgob = NULL;
Iplimage * obimagenmi [255];
Float M [255];
Float J [2, 255];
Float CX [255];
Float CY [255];
For (INT I = 0; I <255; I ++)
{
M [I] = 0.0;
J [I] = 0.0;
CX [I] = 0.0;
CY [I] = 0.0;
Obimagenmi [I] = cvcreateimage (cvsize (SRC-> width, Src-> height), 8, 1 );
Cvzero (obimagenmi [I]);
}
Imgob = cvcreateimage (cvsize (SRC-> width, Src-> height), 8, 1 );
Cvzero (imgob );
Biaoji (SRC );
For (int t = 0; t <= x_sign; t ++)
{
If (flag [T]> 0)
{
For (INT m = 0; m <Src-> height; m ++)
For (INT n = 0; n <Src-> width; n ++)
{
If (cv_image_elem (temp, uchar, m, n) = T)
{
Cv_image_elem (obimagenmi [T], uchar, m, n) = 255;
}
}
For (Int J = 0; j <Src-> height; j ++)
For (I = 0; I <Src-> width; I ++)
{
M [T] + = (INT) cv_image_elem (obimagenmi [T], uchar, J, I );
CX [T] + = J * (INT) cv_image_elem (obimagenmi [T], uchar, J, I );
CY [T] + = I * (INT) cv_image_elem (obimagenmi [T], uchar, J, I );
}
CX [T]/= m [T];
CY [T]/= m [T];
For (j = 0; j <Src-> height; j ++)
For (I = 0; I <Src-> width; I ++)
{
J [T] + = (J-cx [T]) * (J-cx [T]) + (I-cy [T]) * (I-cy [T]) * (INT) (cv_image_elem (obimagenmi [T], uchar, J, I ));
}
J [T] = SQRT (J [T])/m [T];
}
}
For (t = 0; t <= x_sign; t ++)
{
If (J [T]! = 0)
{Cout <"connected zone" <t <"NMI feature value" <J [T] <Endl;
If (FABS (J [T]-modelnmifeature)/J [T]) <= 1-pipei/100)
{
For (INT m = 0; m <Src-> height; m ++)
For (INT n = 0; n <Src-> width; n ++)
{
If (cv_image_elem (temp, uchar, m, n) = T)
Cv_image_elem (imgob, uchar, m, n) = 255;
Status = true;
}
}}
}
For (I = 0; I <255; I ++)
{
Cvreleaseimage (& obimagenmi [I]);
}
Cvcopy (imgob, Src );
Cvreleaseimage (& imgob );
Cvreleaseimage (& temp );
T4 =: gettickcount ();
Cout <"t4-t3 =" <t4-t3 <Endl;
If (Status)
Return true;
Else
Return false;
}