Why i am getting different global maximum value for the same image [closed]
while i am trying to get the global maximum in an image, i recieved two values for the global maximum for the same image.first time, in the method "globMaxValLoc" i get the global maximum and this method yielded 101 at location {111,66}. second time in the methods "findCandidateLocMax", and it yielded 255 at location {106,61}.
please also have a look at the output section below as it contains the output results i am getting.
please let me know why i am getting different global maximum values each time, and is there any better way to get the global maximum?
Update
Or in other words, when I use Core.MinMaxLoc two consecutive times it geives differen values!! why that is happening and how to avoid it.
globMaxValLoc mathod:
private void globMaxValLoc(Mat saliencyMap) {
// TODO Auto-generated method stub
MinMaxLocResult saliencyGlobMax = Core.minMaxLoc(saliencyMap);
Log.D(TAG, "globMaxValLoc", "saliencyGlobMax.maxVal: "+saliencyGlobMax.maxVal);
Log.D(TAG, "globMaxValLoc", "saliencyGlobMax.maxLoc: "+saliencyGlobMax.maxLoc);
Core.rectangle(saliencyMap, new Point(saliencyGlobMax.maxLoc.x-5, saliencyGlobMax.maxLoc.y-5),
new Point(saliencyGlobMax.maxLoc.x+5, saliencyGlobMax.maxLoc.y+5),
new Scalar(255, 100, 200));
ImageUtils.showMat(saliencyMap, "saliencyGlobMax");
this.setGlobMaxVal(saliencyGlobMax.maxVal);
this.setGlobMaxLoc(saliencyGlobMax.maxLoc);
}
findCandidateLocMax
private void findCandidateLocMax(Mat saliencyMap, Point[] frameMinMaxDims) {
// TODO Auto-generated method stub
double topLeftX = frameMinMaxDims[0].x;
double topLeftY = frameMinMaxDims[0].y;
double bottomRightX = frameMinMaxDims[1].x;
double bottomRightY = frameMinMaxDims[1].y;
double diffX = (bottomRightX-topLeftX) + 1;
double diffY = (bottomRightY-topLeftY) + 1;
int cnt = 0;
HashMap<Point, Double> seedsMap = new HashMap<Point, Double>();
Valuecomparator vc = new Valuecomparator(seedsMap);
TreeMap<Point, Double> treeMap = new TreeMap<Point, Double>(vc);
//here i get the global maxima
MinMaxLocResult saliencyGlobMax = Core.minMaxLoc(saliencyMap);
Log.D(TAG, "findCandidateLocMax", "saliencyGlobMax.maxVal: "+saliencyGlobMax.maxVal);
Log.D(TAG, "findCandidateLocMax", "saliencyGlobMax.maxLoc: "+saliencyGlobMax.maxLoc);
Core.rectangle(saliencyMap, new Point(saliencyGlobMax.maxLoc.x-5, saliencyGlobMax.maxLoc.y-5),
new Point(saliencyGlobMax.maxLoc.x+5, saliencyGlobMax.maxLoc.y+5),
new Scalar(255, 100, 200));
ImageUtils.showMat(saliencyMap, "saliencyGlobMax");
OutPut:
6: Debug: FOA -> globMaxValLoc: saliencyGlobMax.maxVal: 101.0
7: Debug: FOA -> globMaxValLoc: saliencyGlobMax.maxLoc: {111.0, 66.0}
8: Debug: FOA -> findCandidateLocMax: saliencyGlobMax.maxVal: 255.0
9: Debug: FOA -> findCandidateLocMax: saliencyGlobMax.maxLoc: {106.0, 61.0}