Ask Your Question

Saghir A. Khatri's profile - activity

2015-10-06 09:16:49 -0600 received badge  Student (source)
2015-08-19 02:47:22 -0600 asked a question porting a statement from C++ to Java

hi all! I have following OpenCv mask statment, which i am unable to convert o my Java android. It is in C++

im1 = cmyk[3].mul(1 - cmyk[1]) > 0.25;

cmyk[1] and im1 are Mat objects.i get following error

The operator - is undefined for the argument type(s) int, Mat

Kindly point me to to right direction. thanks

2015-08-18 06:10:28 -0600 received badge  Enthusiast
2015-08-12 04:59:16 -0600 asked a question trouble porting RGB2CMYK method from c++ to java

I am trying to convert a method from c++ to java. Here is the method:

void rgb2cmyk(cv::Mat& src, std::vector<cv::Mat>& cmyk)
{
    CV_Assert(src.type() == CV_8UC3);

    cmyk.clear();
    for (int i = 0; i < 4; ++i)
        cmyk.push_back(cv::Mat(src.size(), CV_32F));

    for (int i = 0; i < src.rows; ++i)
    {
        for (int j = 0; j < src.cols; ++j)
        {
            cv::Vec3b p = src.at<cv::Vec3b>(i,j);

            float r = p[2] / 255.;
            float g = p[1] / 255.;
            float b = p[0] / 255.;
            float k = (1 - std::max(std::max(r,g),b));

            cmyk[0].at<float>(i,j) = (1 - r - k) / (1 - k); 
            cmyk[1].at<float>(i,j) = (1 - g - k) / (1 - k);
            cmyk[2].at<float>(i,j) = (1 - b - k) / (1 - k);
            cmyk[3].at<float>(i,j) = k;
        }
    }
}

Problem is with the methods of OpenCv. Here is some detail:

  1. I didn't find CV_Assert method in java. dont know any alternate for that.
  2. cmyk.push_back is replaced with cmyk[i].pushback
  3. i have used Mat replacing cv::Vec3b, it is shows no error
  4. std::max is replaced with Math.max
  5. issue is assignment to cmyk[0].at<float>(i,j)

Do any one have suggestion or any better approach of changing this method to java.

Thanks in advance for help....

2015-08-10 01:31:00 -0600 received badge  Scholar (source)
2015-08-05 03:11:39 -0600 commented question unable to determine angle because of points from line

@thdrksdfthmn please elaborate about tangent. Thanks

2015-08-04 08:07:34 -0600 asked a question unable to determine angle because of points from line

I have an image from which i have created some lines. I have saved starting and end points of line. Lines are basically long side of rectangle that is bounding a white blob in image. Rectangles are placed in some circle. Image is shown as below image description

Issue is when rectangle is formed in the lower part of circle, Starting point can be thought as the lower most Point of the circle i.e near the edge of circle, but when Rectangle is formed in the upper part of the circle as shown in the last dial of the image it is difficult to find out which point to choose as the starting point to find out the starting point which is near center of the dial.

Is there any workaround on how i can swap points of line in upper region of circle. Kindly guide me as i am out of ideas with this now.

Here is code to select longest side of rectangle and printing its points

int maxIndex = 0;
for (int a = 1; a < length.length; a++){
    double newnumber = length[a];
    if ((newnumber > length[maxIndex])){
        maxIndex = a;
    }
} 
System.out.println("Start= "+pts[maxIndex].toString()+" End= "+pts[(maxIndex+1)%4].toString()+", Length="+length[maxIndex]);

Regards,