title: Crop the center of the image
body: <p>I am new in OpenCV so please to be patient. I am doing an Android application to measure the similarity of leaf color. I've tried using canny to detect only the leaf area but but I think it requires a longer process. Here is the code, only to the detection of leaf area. </p>
  
  <pre><code>public class editImage extends Activity {
  //private static final int CV_64FC1 = 0;
  protected ImageView im;
  protected String msg_path;
  private Mat mMatriximg;
  
  private Mat mMatriximgBW;
  private int CV_64FC1;
  
  //private Mat mMatriximgBW;
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.image_layout);
  
      im = (ImageView) findViewById(R.id.imV_ed);
      Intent iIdentify = getIntent();
      msg_path = iIdentify.getStringExtra("path");
  
      //to grayscale
      int im_gray = Highgui.CV_LOAD_IMAGE_GRAYSCALE;
      mMatriximg = Highgui.imread(msg_path, im_gray);
  
      // call library OpenCV
      //Imgproc.equalizeHist(mMatriximg, mMatriximg);
      Imgproc.Canny(mMatriximg, mMatriximg, 50, 150);
  
      mMatriximgBW = Mat.zeros(mMatriximg.height(), mMatriximg.width(), CV_64FC1);
  
      double y;
      double threshold=190;
  
      for(int i=0; i&lt;mMatriximg.height(); i++){
          for(int j=0; j&lt;mMatriximg.width(); j++){
              if(mMatriximg.get(i, j) [0]&gt;=threshold){
                  y=255;
              }else{
                  y=0;        
              }
              mMatriximgBW.put(i, j, new double[] {y});
          }
      }
  
      //result mat to Grayscale
      Imgproc.cvtColor(mMatriximgBW, mMatriximgBW, Imgproc.COLOR_GRAY2RGBA, 4);
  
      Bitmap bmpOut = Bitmap.createBitmap(mMatriximgBW.cols(), mMatriximgBW.rows(), Bitmap.Config.ARGB_8888);
  
      Utils.matToBitmap(mMatriximgBW, bmpOut);
      im.setImageBitmap(bmpOut);
  
  }
  
  public void bckHome(View v){
      Intent iIden = new Intent(this, MBWDActivity.class);
      setResult(RESULT_OK, iIden);
      startActivityForResult(iIden, 99);
  }
  }
  </code></pre>
  
  <p>So I thought it would be more efficient if i cut out the center of the leaf as the sample data (matrix). </p>
  
  <p>is there who can share on how to implement cvSetImageROI or other methods?</p>
  
  <p>Thank you for any help</p>