2015-07-12 1 views
1

Je souhaite remplir une zone donnée "le rectangle sur le côté gauche" de l'image affichée ci-dessous. à FloodFill cette zone, i spécifié un point à l'intérieur que le rectangle de connaître la valeur du pixel de la manière suivante:L'algorithme FloodFill se remplit au-delà des limites spécifiées

Log.D(TAG, "", "PixVal: "+gsMat.get(100, 240)[0]);//at that position the pixVal is 91 up ok 
    Log.D(TAG, "", "PixVal: "+gsMat.get(250, 60)[0]);//at that position the pixVal is 217 l ??peoblem 
    Log.D(TAG, "", "PixVal: "+gsMat.get(330, 310)[0]);//at that position the pixVal is 123 down ok 
    Log.D(TAG, "", "PixVal: "+gsMat.get(330, 580)[0]);//at that position the pixVal is 84 r ok 

et je suis sûr que le point (x = 60, y = 250) fixe à l'intérieur de ce rectangle sur la la gauche. et j'ai écrit le code ci-dessous pour suivre cette zone. mais je suis les images affichées ci-dessous comme résultat

"Mat subbed = gsRawMat.submat(r)" shows the whole orignal image as if the the whole pixel values in the image lays within the range of 216 to 218? 

"ImageUtils.showMat(subbed, "subbed");" shows a white image as if the the whole pixel values in the image lays within the range of 216 to 218, hence, the whole area painted in white (255)? 

s'il vous plaît laissez-moi savoir pourquoi ce problème se produit

code:

Mat m = new Mat(); 
    Rect r = new Rect(); 
    Imgproc.floodFill(gsMat, 
      m, 
      new Point(60, 250), 
      new Scalar(255),//to fill the designated area with color(255) 
      r,//the rect that will encompass the designated area 
      new Scalar(216),//lower bound 
      new Scalar(218),//upper bound 
      Imgproc.FLOODFILL_FIXED_RANGE); 

    Mat subbed = gsRawMat.submat(r);// to extract the rectangle contains the flooded area from the main image 
    ImageUtils.showMat(gsMat, "gsMat");//to show the gsmat 
    ImageUtils.showMat(subbed, "subbed");//to show the subbed area from the gsMat 

résultats gsMat: enter image description here

résultat mat subbed: enter image description here

+0

Cela aiderait beaucoup si vous avez inclus le résultat depuis votre description me semble un peu floue à. – runDOSrun

+0

@runDOSrun jetez un oeil à la quête. J'ai mis à jour toute la question – user2121

Répondre

1

utilisateur n'a pas utilisé cette fonction, mais en fonction de la (C++) documentation, les paramètres ne sont pas « limite inférieure » et « limite supérieure », mais « différence inférieur » et « différence supérieure » . Leurs valeurs de luminosité/couleur sont relatives au point de graine x = 60, y = 250. Je n'ai pas eu le temps d'y réfléchir, mais cela pourrait-il être responsable?

http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#floodfill