static void test(IplImage *b) { CvSize s = cvGetSize(b); //s.width /= 2; //s.height /= 2; IplImage *rsz = alignedImage(s, b->depth, b->nChannels, 8); cvResize(b, rsz, CV_INTER_CUBIC); IplImage *sal = saliency(rsz); cvShowImage("saliency", sal); cvReleaseImage(&rsz); cvReleaseImage(&sal); return; }
void OpenSnakeTracer::Cast_Open_Snake_3D( PointList3D seeds, bool manual_seed ) { //int iter_num = 50; if( manual_seed ) { //std::cout<<"manual seed"<<std::endl; int SM = IM->I->GetLargestPossibleRegion().GetSize()[0]; int SN = IM->I->GetLargestPossibleRegion().GetSize()[1]; int SZ = IM->I->GetLargestPossibleRegion().GetSize()[2]; PointList3D temp_seeds; for( int j = 0; j < seeds.NP; j++ ) { if( seeds.Pt[j].z != 0 ) { temp_seeds.AddPt(seeds.Pt[j]); continue; } ProbImageType::IndexType index; ImageType::IndexType index1; index[0] = seeds.Pt[j].x; index1[0] = seeds.Pt[j].x; index[1] = seeds.Pt[j].y; index1[1] = seeds.Pt[j].y; vnl_vector<float> saliency(SZ); saliency.fill(0); bool skeleton_point = false; for( int i = 0; i < SZ; i++ ) { index[2] = i; index1[2] = i; /*if( IM->SBW->GetPixel( index1 ) == 1 ) { seeds.Pt[j].z = i; seeds.Pt[j].check_out_of_range_3D(SM,SN,SZ); temp_seeds.AddPt(seeds.Pt[j]); skeleton_point = true; break; }*/ //if( IM->VBW->GetPixel( index1 ) == 1 ) saliency(i) = IM->I->GetPixel( index ); } if( !skeleton_point ) { int idx = saliency.arg_max(); //if( saliency.max_value() == 0 && j > 0 ) //{ // seeds.Pt[j].z = seeds.Pt[j-1].z; // seeds.Pt[j].check_out_of_range_3D(SM,SN,SZ); //break; //} seeds.Pt[j].z = idx; seeds.Pt[j].check_out_of_range_3D(SM,SN,SZ); //if( saliency.arg_max() != 0 ) temp_seeds.AddPt(seeds.Pt[j]); } } if( temp_seeds.NP == 2 ) { seeds.RemoveAllPts(); seeds.AddPt(temp_seeds.Pt[0]); } else { seeds = temp_seeds; } tracing_thread->manual_seed = true; } else { tracing_thread->manual_seed = false; } tracing_thread->setParas( &SnakeList, seeds, IM, options); //in case of going back to preprocessing step, stopped is ture and hence it needs to be reset if( SnakeList.NSnakes == 0 ) { tracing_thread->stopped = false; } tracing = true; std::cout<<"Start the tracing......"<<std::endl; tracing_thread->start(); }