MCPcopy Create free account
hub / github.com/creatale/node-dv / icvNewSolution

Function icvNewSolution

deps/opencv/modules/imgproc/src/emd.cpp:725–802  ·  view source on GitHub ↗

\ * icvNewSolution * \****************************************************************************************/

Source from the content-addressed store, hash-verified

723* icvNewSolution *
724\****************************************************************************************/
725static bool
726icvNewSolution( CvEMDState * state )
727{
728 int i, j;
729 float min_val = CV_EMD_INF;
730 int steps;
731 CvNode2D head, *cur_x, *next_x, *leave_x = 0;
732 CvNode2D *enter_x = state->enter_x;
733 CvNode2D **loop = state->loop;
734
735 /* enter the new basic variable */
736 i = enter_x->i;
737 j = enter_x->j;
738 state->is_x[i][j] = 1;
739 enter_x->next[0] = state->rows_x[i];
740 enter_x->next[1] = state->cols_x[j];
741 enter_x->val = 0;
742 state->rows_x[i] = enter_x;
743 state->cols_x[j] = enter_x;
744
745 /* find a chain reaction */
746 steps = icvFindLoop( state );
747
748 if( steps == 0 )
749 return false;
750
751 /* find the largest value in the loop */
752 for( i = 1; i < steps; i += 2 )
753 {
754 float temp = loop[i]->val;
755
756 if( min_val > temp )
757 {
758 leave_x = loop[i];
759 min_val = temp;
760 }
761 }
762
763 /* update the loop */
764 for( i = 0; i < steps; i += 2 )
765 {
766 float temp0 = loop[i]->val + min_val;
767 float temp1 = loop[i + 1]->val - min_val;
768
769 loop[i]->val = temp0;
770 loop[i + 1]->val = temp1;
771 }
772
773 /* remove the leaving basic variable */
774 i = leave_x->i;
775 j = leave_x->j;
776 state->is_x[i][j] = 0;
777
778 head.next[0] = state->rows_x[i];
779 cur_x = &head;
780 while( (next_x = cur_x->next[0]) != leave_x )
781 {
782 cur_x = next_x;

Callers 1

cvCalcEMD2Function · 0.85

Calls 1

icvFindLoopFunction · 0.85

Tested by

no test coverage detected