SalientRegionSegmenter.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef SALIENT_REGION_SEGMENTER
00041 #define SALIENT_REGION_SEGMENTER
00042
00043 #include "Gist/SuperPixel.H"
00044 #include "Gist/ContourBoundaryDetector.H"
00045 #include "SIFT/Histogram.H"
00046
00047 struct Segment
00048 {
00049 Segment() { };
00050
00051 Segment(const int inOrgIndex,
00052 const int inContourIndex,
00053 const int inSegStartIndex,
00054 const int inSegEndIndex) :
00055 orgIndex (inOrgIndex),
00056 contourIndex (inContourIndex),
00057 segStartIndex(inSegStartIndex),
00058 segEndIndex (inSegEndIndex)
00059 {
00060 pVal = 0.0;
00061 lenVal = 0.0;
00062 simVal = 0.0;
00063 strVal = 0.0;
00064 ratVal = 0.0;
00065 disVal = 0.0;
00066 }
00067
00068 uint orgIndex;
00069 uint contourIndex;
00070 uint segStartIndex;
00071 uint segEndIndex;
00072
00073 float strength;
00074
00075 float pVal;
00076 float lenVal;
00077 float simVal;
00078 float strVal;
00079 float ratVal;
00080 float disVal;
00081
00082
00083 bool operator < (const Segment& other)
00084 {
00085 return pVal > other.pVal;
00086 }
00087 };
00088
00089
00090
00091
00092
00093 class SalientRegionSegmenter
00094 {
00095 public:
00096
00097
00098
00099
00100
00101
00102 SalientRegionSegmenter();
00103
00104
00105 ~SalientRegionSegmenter();
00106
00107
00108 void setImage(Image<PixRGB<byte> > image);
00109
00110
00111
00112 Image<float> getSalientRegion(Point2D<int> pt);
00113
00114
00115
00116
00117
00118
00119
00120
00121 inline Image<PixRGB<byte> > getImage();
00122
00123
00124
00125 private:
00126
00127
00128 Image<PixRGB<byte> > itsImage;
00129
00130
00131 Image<rutz::shared_ptr<Histogram> > itsImageFeatureHistogram;
00132
00133
00134 rutz::shared_ptr<ContourBoundaryDetector>
00135 itsContourBoundaryDetector;
00136
00137
00138
00139
00140
00141
00142 Image<float> itsSalientRegionImage;
00143
00144
00145
00146 std::vector<Point2D<int> > itsSalientPoints;
00147
00148
00149
00150 Image<int> itsInitialRegionImage;
00151
00152
00153
00154 std::vector<std::vector<Point2D<int> > > itsInitialRegions;
00155
00156
00157
00158 Image<PixRGB<byte> > itsInitialRegionColorImage;
00159
00160
00161 std::vector<std::vector<uint> > itsRegionAdjecencyList;
00162
00163
00164 std::vector<rutz::shared_ptr<Contour> > itsContourBoundaries;
00165
00166
00167 float itsMaximumEdgelStrength;
00168
00169
00170
00171
00172 std::vector<Image<int> > itsImageHistogramEntries;
00173
00174
00175 Image<float> itsLKernel;
00176 Image<float> itsAKernel;
00177 Image<float> itsBKernel;
00178
00179
00180 Image<rutz::shared_ptr<Histogram> > itsComputedHistograms;
00181
00182
00183 rutz::shared_ptr<XWinManaged> itsWin;
00184
00185
00186
00187
00188
00189
00190 void computeBoundaryAndRegionInformation();
00191
00192
00193 void computeBoundaryInformation();
00194
00195
00196 void computeRegionInformation();
00197
00198
00199 std::vector<std::vector<uint> > getRegionAdjecencyList();
00200
00201
00202 void displayRegionAdjecencyList();
00203
00204
00205 void displayBoundaryAndRegionInformation();
00206
00207
00208
00209 void computeSalientRegion();
00210
00211
00212
00213 std::list<Segment> fillSegmentQueue(Point2D<int> pt);
00214
00215
00216 void setPriority(Segment &segment, Point2D<int> pt);
00217
00218
00219 Histogram getHistogramDistribution(Point2D<int> pt);
00220
00221
00222 Histogram getHistogramDistribution (std::vector<Point2D<int> > pts);
00223
00224
00225
00226 void getSegmentPointDistributions
00227 (Segment segment, Point2D<int> pt,
00228 std::vector<Point2D<int> > &pts1,
00229 std::vector<Point2D<int> > &pts2);
00230
00231
00232 void setImageFeatureHistogramValues();
00233
00234
00235 Image<int> quantize_values
00236 (Image<float> image, int num_bins, bool normalize = false);
00237
00238
00239 void filterSegments(std::list<Segment> &segments);
00240
00241
00242 void addUnvisitedNeighbors
00243 (std::vector<Point2D<int> > ¤tUnassignedLocations,
00244 Point2D<int> currPoint,
00245 Image<int> &assignmentMap);
00246
00247
00248 std::vector<Point2D<int> > getLine
00249 (Point2D<int> p1, Point2D<int> p2);
00250
00251
00252 void assignRegionsAroundSegment
00253 (Segment segment,
00254 std::vector<Point2D<int> > pts2,
00255 std::vector<Point2D<int> > pts3,
00256 Image<int> &assignmentMap,
00257 std::vector<Point2D<int> > ¤tObjectLocations,
00258 std::vector<Point2D<int> > ¤tBackgroundLocations,
00259 std::vector<Point2D<int> > ¤tUnassignedLocations,
00260 Image<int> ®ionAssignmentMap,
00261 std::vector<int> ¤tObjectRegionList,
00262 std::vector<int> ¤tBackgroundRegionList);
00263
00264
00265 void displayDistributionSetup
00266 (Segment segment, Point2D<int> pt,
00267 std::vector<Point2D<int> > pts2,
00268 std::vector<Point2D<int> > pts3);
00269
00270
00271 void displayGrowMap
00272 (Image<int> assignmentMap, Point2D<int> currPoint,
00273 std::vector<Point2D<int> > currentObjectLocations,
00274 std::vector<Point2D<int> > currentObjectCoreLocations,
00275 std::vector<Point2D<int> > currentBackgroundLocations,
00276 std::vector<Point2D<int> > currentUnassignedLocations,
00277 Image<bool> isComparedWith, Segment segment);
00278
00279
00280 };
00281
00282
00283
00284
00285 inline Image<PixRGB<byte> > SalientRegionSegmenter::getImage()
00286 { return itsImage; }
00287
00288 #endif
00289
00290
00291
00292
00293
00294