#include "HxSF.h"
Go to the source code of this file.
Functions | |
HxImageRep L_HXIMAGEREP | HxRegionalMinima (HxImageRep im, int conn) |
function y=mmregmin_equ( f, bc) fminus = mmsubm(f,1); g = mmsubm(mmsuprec(f,fminus,bc),fminus); y = mmunion(mmthreshad(g,1),mmthreshad(f,0,0));. More... |
|
function y=mmregmin_equ( f, bc) fminus = mmsubm(f,1); g = mmsubm(mmsuprec(f,fminus,bc),fminus); y = mmunion(mmthreshad(g,1),mmthreshad(f,0,0));.
00055 { 00056 HxImageRep res; 00057 00058 //in this list I put the labels representing regional maxima 00059 //this list will be used for LUT 00060 std::vector<int> regMinList; 00061 //regMinList.clear(); 00062 00063 BasicFeaturesList bfl=HxGetBlobFeatures(im, res, conn, 0); 00064 //printf("bfl size=%d\n", bfl.size()); 00065 for(int ix=0;ix<bfl.size();ix++) 00066 { 00067 //this function works for gray images, not for color 00068 int cval = bfl[ix]->val.x(); 00069 //now check if the the current value is the minimum among the neighbours 00070 //now find the gray value of that neighbor 00071 int nval; 00072 int minnval=INT_MAX; 00073 for(int i=0;i<bfl[ix]->neighbors.size();i++) 00074 { 00075 nval=bfl[ix]->neighbors[i]->val.x(); 00076 if(nval<minnval) 00077 minnval=nval; 00078 } 00079 if(cval < minnval && minnval<INT_MAX) 00080 { 00081 regMinList.push_back(bfl[ix]->label); 00082 // printf("cval=%3d, maxN=%3d\n",cval,maxnval); 00083 } 00084 } 00085 00086 //now make the LUT from the list of regional minima 00087 std::map<int,int> lut; 00088 int i; 00089 //lut is zero everywhere except the regional maxima position 00090 //here should be from minVal to MaxVal, not from 0 to 255 00091 for(i=0;i<256;i++) 00092 lut[i]=0; 00093 00094 for(i=0;i<regMinList.size();i++) 00095 lut[regMinList[i]] = 255; 00096 00097 00098 res = HxLUT(res, &lut); 00100 00101 00102 HX_COUT << "nr of regional Minima blobs=" << regMinList.size() << STD_ENDL; 00103 return res; 00104 } |