Ask Your Question

opencvnoob29838's profile - activity

2015-05-01 17:41:53 -0500 received badge  Editor (source)
2015-05-01 17:18:39 -0500 asked a question opencv java 2.4.9 pixel operations

Hello everyone!

I am a noob to opencv java and I've been having trouble performing pixel operations on 2 mats. I've already looked at

But it doesn't seem to work....

In opencv c++ the following is pixel division I have performed between 2 Mats which are split into arrays.

  split(top, top_chs);                               
  split(input.clone(), bot_chs);        // split into channels which are vector<Mat>
  split(input.clone(), dst_chs);               

  for (int i = 0; i < top.rows(); i++){
    for (int k = 0; k < top.cols(); k++){
      for (int j = 0; j < top.channels(); j++){
         float a,b,c;

         a = top_chs[j].at<float>(i,k);
         b = bot_chs[j].at<float>(i,k);

         if (a <= 0){a = top_min;} // make sure you don't divide by zero
         if (b <= 0){b = ms_min;}  // make sure you really don't divide by zero

         if (a <= b){c = 1.0 - a/b;}
         else       {c = 1.0 - b/a;}

         dst_chs[j].at<float>(i,k) = c;
  merge(dst_chs, dst);

However to get the same effect in java I am having trouble... getting nothing but run time errors at this part of my code, I've tried the following. However, I get invalid Mat type error 5

    top = UP_Pyramid.get(PyrSize-1);
    bot = MeanShift.clone();

    //      might be needed.... we'll see
    //      Core.split(top, top_chs);
    //      Core.split(input, bot_chs);
    //      Core.split(input, bot_chs);

    // ********************************************************** 
    float a,b, c;

    for (int i = 0; i < top.rows(); i++){
        for (int j = 0; j < top.cols(); j++){
             a = top.get(i,j);
             b = bot.get(i,j);
             if (a <= b) {c = 1.0 - a/b;}
             else         {c = 1.0 - b/a;}
             dst.put(i,j, c);           
2015-05-01 16:17:15 -0500 commented answer max and min values in a Mat

is there any way to do this for a float? or do i have to write my own?

2015-05-01 13:42:43 -0500 received badge  Enthusiast
2015-04-20 10:58:45 -0500 asked a question Calculating euclidian distance over a single mat

Hello, I've been trying to implement the following saliency detector and I'm really struggling to implement the part where it calculates the euclidean distance over an array mat

Anyone able to help me out? I can't seem to find anything that's related to this particular method in implementation.