void CamShiftPlugin::OnOK() { wxBeginBusyCursor(); if (!GetScope()) ProcessImage(cm->book[cm->GetPos()], cm->GetPos()); else{ FetchParams(); ImagePlus *oimg; CvRect orect, searchwin; CvPoint ocenter; oimg = cm->book[0]; int numContours = (int) oimg->contourArray.size(); for (int i=1; i<cm->GetFrameCount(); i++) cm->book[i]->CloneContours(oimg); int frameCount = cm->GetFrameCount(); CreateProgressDlg(numContours*frameCount); bool cont=true; for (int j=0; j<numContours && cont; j++){ for (int i=1; i<frameCount && (cont=progressDlg->Update(j*frameCount+i, wxString::Format("Cell %d of %d, Frame %d of %d", j+1,numContours, i+1, frameCount))); i++){ ProcessStatic(j, cm->book[i], cm->book[useFirst ? 0 : i-1], hsizes, criteria, planes, hist, backproject, orect, ocenter, searchwin, rotation, shift, i>1); } } DestroyProgressDlg(); } cm->ReloadCurrentFrameContours(true, false); wxEndBusyCursor(); }
void MatchTemplatePlugin::ProcessImage( ImagePlus* img, int pos, int zPos ) { if (pos==0) return; FetchParams(); ImagePlus *oimg = cm->Access(useFirst ? 0 : pos-1, zPos); img->CloneContours(oimg); int numContours = (int) oimg->contourArray.size(); for (int i=0; i<numContours; i++){ ProcessStatic(i, img, oimg, method, winsize, map); } cm->Release(useFirst ? 0 : pos-1, zPos, false); }
void CamShiftPlugin::ProcessImage( ImagePlus* img, int pos ) { if (pos==0) return; FetchParams(); ImagePlus *oimg = cm->book[useFirst ? 0 : pos-1]; CvRect orect, searchwin; CvPoint ocenter; img->CloneContours(oimg); int numContours = (int) oimg->contourArray.size(); for (int i=0; i<numContours; i++){ ProcessStatic(i, img, oimg, hsizes, criteria, planes, hist, backproject, orect, ocenter, searchwin, rotation, shift, false); } }
void FindFeaturesPlugin::ProcessImage( ImagePlus *img ){ FetchParams(); IplImage *orig = img->orig; if (!gray){ gray = cvCreateImage( cvGetSize(orig), IPL_DEPTH_8U, 1 ); cnt_mask = cvCreateImage(cvGetSize(orig), IPL_DEPTH_8U, 1); eig = cvCreateImage( cvGetSize(orig), IPL_DEPTH_32F, 1 ); tempimg = cvCreateImage(cvGetSize(orig), IPL_DEPTH_32F, 1); } cvCvtColor(orig, gray, CV_BGR2GRAY); CvPoint2D32f* feats = (CvPoint2D32f*)malloc(maxCount*sizeof(CvPoint2D32f)); for(int c=0; c<(int)img->contourArray.size(); c++){ int count = maxCount; CvSeq *seq = img->contourArray[c]; cvZero(cnt_mask); CvSeq *h_next = seq->h_next; seq->h_next = NULL; cvDrawContours(cnt_mask, seq, CV_RGB(255,255,255), CV_RGB(0,0,0), 1, CV_FILLED, CV_AA, cvPoint(0,0)); seq->h_next = h_next; cvGoodFeaturesToTrack( gray, eig, tempimg, feats, &count, quality, minDist, cnt_mask, blockSize, method, harrisK ); img->AddFeats(c, feats, count, clean); } free(feats); }
void MatchTemplatePlugin::OnOK() { wxBeginBusyCursor(); if (GetScope() == 0) // single { if (GetScope2() != 1) // both and normal { ProcessImage( cm->Access(cm->GetPos(),cm->GetZPos(), false), cm->GetPos(), cm->GetZPos()); cm->Release(cm->GetPos(), cm->GetZPos(), false); } if (GetScope2() != 0) // both and fluorescence { ProcessImage( cm->Access(cm->GetPos(),cm->GetZPos(), true), cm->GetPos(), cm->GetZPos()); cm->Release(cm->GetPos(), cm->GetZPos(), true); } } else if (GetScope() == 2) // t-direction { FetchParams(); ImagePlus *oimg; CvRect orect, searchwin; CvPoint ocenter; int frameCount = cm->GetFrameCount(); CreateProgressDlg(frameCount*(GetScope2()==2?2:1)); if (GetScope2() != 1) // both and normal { oimg = cm->Access(0,cm->GetZPos()); int numContours = (int) oimg->contourArray.size(); //cm->Release(0,0, false); for (int i=1; i<frameCount; i++) cm->Access(i,cm->GetZPos(),false,true)->CloneContours(oimg); for (int i=1; i<frameCount && progressDlg->Update(i, wxString::Format(_T("Frame %d of %d"), i+1, frameCount)); i++) { for (int j=0; j<numContours; j++) { ProcessStatic(j, cm->Access(i,cm->GetZPos(), false, false, GetScope()), cm->Access(useFirst ? 0 : i-1,cm->GetZPos()), method, winsize, map); } cm->Release(i-1,cm->GetZPos(),false); } cm->Release(frameCount-1,cm->GetZPos(),false); cm->Release(0,cm->GetZPos(),false); } if (GetScope2() != 0) // both and fluorescence { oimg = cm->Access(0,cm->GetZPos(), true); int numContours = (int) oimg->contourArray.size(); //cm->Release(0,0, false); for (int i=1; i<frameCount; i++) cm->Access(i,cm->GetZPos(),true,true)->CloneContours(oimg); for (int i=1; i<frameCount && progressDlg->Update(i+(GetScope2()==2?frameCount:0), wxString::Format(_T("Frame %d of %d"), i+1, frameCount)); i++) { for (int j=0; j<numContours; j++) { ProcessStatic(j, cm->Access(i,cm->GetZPos(), true, false, GetScope()), cm->Access(useFirst ? 0 : i-1,cm->GetZPos()), method, winsize, map); } cm->Release(i-1,cm->GetZPos(),true); } cm->Release(frameCount-1,cm->GetZPos(),true); cm->Release(0,cm->GetZPos(),true); } DestroyProgressDlg(); } else if (GetScope() == 3) // z-direction { FetchParams(); ImagePlus *oimg; CvRect orect, searchwin; CvPoint ocenter; int slideCount = cm->slideCount; CreateProgressDlg(slideCount*(GetScope2()==2?2:1)); if (GetScope2() != 1) // both and normal { for (int i=1; i<slideCount && progressDlg->Update(i, wxString::Format(_T("Slide %d of %d"), i+1, slideCount)); i++) { oimg = cm->Access(0,i); int numContours = (int) oimg->contourArray.size(); cm->Access(cm->GetPos(),i,false,true)->CloneContours(oimg); for (int j=0; j<numContours; j++) { ProcessStatic(j, cm->Access(cm->GetPos(),i, false, false, GetScope()), cm->Access(useFirst ? 0 : cm->GetPos()-1, i), method, winsize, map); } cm->Release(cm->GetPos(),i,false); cm->Release(cm->GetPos()-1,i,false); cm->Release(0,i,false); } } if (GetScope2() != 0) // both and fluorescence { for (int i=1; i<slideCount && progressDlg->Update(i+(GetScope2()==2?slideCount:0), wxString::Format(_T("Slide %d of %d"), i+1, slideCount)); i++) { oimg = cm->Access(0,i, true); int numContours = (int) oimg->contourArray.size(); cm->Access(cm->GetPos(),i,true,true)->CloneContours(oimg); for (int j=0; j<numContours; j++) { ProcessStatic(j, cm->Access(cm->GetPos(),i, true, false, GetScope()), cm->Access(useFirst ? 0 : cm->GetPos()-1, i), method, winsize, map); } cm->Release(cm->GetPos(),i,true); cm->Release(cm->GetPos()-1,i,true); cm->Release(0,i,true); } } DestroyProgressDlg(); } else { FetchParams(); ImagePlus* oimg; int frameCount = cm->GetFrameCount(); int slideCount = cm->slideCount; CreateProgressDlg(frameCount*slideCount*(GetScope2()==2?2:1)); bool cont=true; for (int slide = 0; slide < slideCount && cont; slide++) { if (GetScope2() != 1) // both and normal { oimg = cm->Access(0, slide,false); for (int i=1; i<frameCount; i++) cm->Access(i,slide,false,true)->CloneContours(oimg); int numContours = (int) oimg->contourArray.size(); for (int i=1; i<frameCount && (cont=progressDlg->Update(slide*frameCount+i, wxString::Format(_T("Frame %d of %d, Slide %d of %d"), i+1, frameCount, slide+1, slideCount))); i++) { for (int j=0; j<numContours; j++) { ProcessStatic(j, cm->Access(i,slide, false, false, GetScope()), cm->Access(useFirst ? 0 : i-1,slide), method, winsize, map); } cm->Release(i-1,slide,false); } cm->Release(frameCount-1,slide,false); cm->Release(0,slide,false); } if (GetScope2() != 0) // both and fluorescence { oimg = cm->Access(0, slide, true); for (int i=1; i<frameCount; i++) cm->Access(i,slide,true,true)->CloneContours(oimg); int numContours = (int) oimg->contourArray.size(); for (int i=1; i<frameCount && cont; i++) { for (int j=0; j<numContours && (cont=progressDlg->Update(slide*frameCount+i+(GetScope2()==2?frameCount*slideCount:0), wxString::Format(_T("Cell %d of %d, Frame %d of %d"), j+1,numContours, i+1, frameCount))); j++) { ProcessStatic(j, cm->Access(i,slide, true, false, GetScope()), cm->Access(useFirst ? 0 : i-1,slide), method, winsize, map); } cm->Release(i-1,slide,true); } cm->Release(frameCount-1,slide,true); cm->Release(0,slide,true); } } DestroyProgressDlg(); } cm->ReloadCurrentFrameContours(true, false); wxEndBusyCursor(); }