Ask Your Question

mariusz's profile - activity

2018-08-07 14:44:04 -0500 answered a question failed to build through the scripte of the platforms/android/build_sdk.py

Do yo know when latest build tools 27.0.3 and gradle will be supported?

2018-07-27 15:22:02 -0500 received badge  Enthusiast
2018-07-23 12:15:22 -0500 received badge  Editor (source)
2018-07-23 12:15:22 -0500 edited question triangulation for image

triangulation for image Hi, How can I generate triangulation similar to below files: C:\fakepath\doberman.jpg C:\fake

2018-07-23 12:14:26 -0500 asked a question triangulation for image

triangulation for image Hi, How can I generate triangulation similar to below files: (/upfiles/15323659009392009.png) (

2015-11-15 10:33:18 -0500 asked a question Count pixels

Hi,

Below my implementation of function countPixels. Does exist better OpenCv/matrix way? cv::countNonZero works only for on channel image.

int countPixels(const cv::Mat &image, cv::Scalar color) {
  int result = 0;
  for (int y = 0; y < image.rows; y++) {
    const cv::Vec4b *rowImage = image.ptr<cv::Vec4b>(y);
    for (int x = 0; x < image.cols; x++) {
      if (rowImage[x][0] == color[0] && rowImage[x][1] == color[1] &&
          rowImage[x][2] == color[2] && rowImage[x][3] == color[3]) {
        ++result;
      }
    }
  }
  return result;
}

Thanks Mariusz

2015-09-01 17:04:12 -0500 asked a question How to create 3d button

Hi,

How to create 3d button from rectangle? My goal is to have a function with output similar to: http://www.imagemagick.org/Usage/adva...

Could you send me any ideas how to do it in OpenCV?

Thank you in advance, Mariusz

2015-05-30 05:14:38 -0500 answered a question Efficient, generic scan image

Below my implementation

void join(cv::Mat& image1, const cv::Mat& image2)
{
    assert(image1.rows == image2.rows);
    assert(image1.cols == image2.cols);

    std::vector<cv::Mat> channels;
    std::vector<cv::Mat> channels2;
    cv::split(image1, channels);
    cv::split(image2, channels2);

    cv::Mat c1 = (255.0 - channels2[3]) / 255.0;
    cv::Mat c2 = channels2[3] / 255.0;
    for (size_t i = 0; i < 3; i++)
    {
        channels[i] = channels[i].mul(c1) + channels2[i].mul(c2);
    }
    cv::merge(channels, image1);
}
2015-05-29 13:24:57 -0500 commented question Optimize - draw gradient function

Could you help me write it as matrix operation?

2015-05-28 17:02:36 -0500 asked a question Optimize - draw gradient function

Hi,

Performance analysis shows me that below function is the slowest function in my program. Is it possible to optimize performance of this gradient function? (i.e. by some matrix operation)

void gradient(cv::Mat& image, cv::Scalar c1, cv::Scalar c2)
{
    auto alphaStep = 1.0 / image.rows;
    auto alpha = 0.0;
    for (int y = 0; y < image.rows; y++) {
        cv::Vec4b* rowImage = image.ptr<cv::Vec4b>(y);
        cv::Scalar color(c1(0)*(1 - alpha) + c2(0)*(alpha), c1(1)*(1 - alpha) + c2(1)*(alpha), c1(2)*(1 - alpha) + c2(2)*(alpha), 255);
        for (int x = 0; x < image.cols; x++) {
            rowImage[x][0] = color[0];
            rowImage[x][1] = color[1];
            rowImage[x][2] = color[2];
            rowImage[x][3] = color[3];
        }
        alpha += alphaStep;
    }
}
2015-05-28 16:29:59 -0500 commented question Efficient, generic scan image

I do not know how to use operators instead of below three lines. Could you write it for me?

double c1 = (255 - (*it2)[3]) / 255.0;
double c2 = (*it2)[3] / 255.0;
(*it)[0] = (*it)[0] * c1 + (*it2)[0] * c2;

Thank you in advance.

2015-05-27 21:51:15 -0500 received badge  Student (source)
2015-05-27 16:13:47 -0500 commented question Efficient, generic scan image

Thank you for answer. Sorry I provided probably but example. I know that we have also converTo image.convertTo(new_image, -1, alpha, beta);

But What about below code. Join two images base on alpha channel of image2.

    void join(cv::Mat& image, const cv::Mat& image2)
    {
        assert(image.rows == image2.rows);
        assert(image.cols == image2.cols);

        auto it = image.begin<cv::Vec4b>();
        auto it2 = image2.begin<cv::Vec4b>();
        const auto itEnd = image.end<cv::Vec4b>();
        for (; it != itEnd; ++it, ++it2)
        {
            double c1 = (255 - (*it2)[3]) / 255.0;
            double c2 = (*it2)[3] / 255.0;
            (*it)[0] = (*it)[0] * c1 + (*it2)[0] * c2;
            (*it)[1] = (*it)[1] * c1 + (*it2)[1] * c2;
            (*it)[2] = (*it)
(*it)[3] = 255;
    }
    }
2015-05-27 15:54:04 -0500 asked a question Efficient, generic scan image

Hi,

Is there any generic OpenCV function/algorithm (like C++ std::transform) to perform pixel modification. I know that I can write i.e. below code. But is neither generic nor efficient.

cv::Mat image;
cv::Mat new_image;

for( int y = 0; y < image.rows; y++ )
   { for( int x = 0; x < image.cols; x++ )
        { for( int c = 0; c < 3; c++ )
             { new_image.at<Vec3b>(y,x)[c] =
                         saturate_cast<uchar>( alpha*( image.at<Vec3b>(y,x)[c] ) + beta ); }
   }
}

I would like to use it like i.e.

cv::Mat src;
cv::Mat dst;
transform(src, dst, pixelUnaryFunctor);

cv::Mat src1;
cv::Mat src2;
cv::Mat dst;
transform(src1, src2, dst, pixelBinaryFunctor);