Ask Your Question

harfbuzz's profile - activity

2019-07-01 09:21:36 -0600 received badge  Notable Question (source)
2019-04-26 09:03:40 -0600 asked a question Assign two threshold values for two ranges of pixels

Assign two threshold values for two ranges of pixels I would like to ask if I can assign two values of the theresholdin

2019-04-26 08:51:32 -0600 answered a question 3d reconstruction

sjhalayka: I'm sorry for my late reply. I just connected to the opencv website. Thank you very much for your help.

2019-02-26 12:07:12 -0600 received badge  Student (source)
2019-02-26 05:08:54 -0600 commented question 3d reconstruction

may be the 3d reconstruction is not within the scope of the opencv processing

2019-02-21 10:21:01 -0600 asked a question 3d reconstruction

3d reconstruction I am looking for openCV functions that can reconstruct series of grayscale 2D-images of a porous mater

2019-02-21 05:14:36 -0600 asked a question grayscale image pixel-based detect object

grayscale image pixel-based detect opbject I would like to know if opencv allows to detect objects of grayscale image ac

2018-08-04 13:10:13 -0600 received badge  Popular Question (source)
2016-10-16 04:50:29 -0600 commented answer How save multiple image in a "BOOST_FOREACH" loop

In order to save files in a new folder, e.g. myFolder, instead of the current directory I've used cv::String filename = format("/path_to_myFolder/imgBlur%d.png", b); but the png files have been saved on both current directory and myFolder. Maybe I missed to add something at this command ?

2016-10-13 10:41:50 -0600 commented answer reading a sequence of files within a folder

thanks a lot,

2016-10-13 10:39:14 -0600 commented answer reading a sequence of files within a folder

The solution given by Theodor takes into account all files with extension e.g. .png ? In order to read and to show the second image in the folder for example how I use it ?

2016-10-13 05:35:24 -0600 commented answer How save multiple image in a "BOOST_FOREACH" loop

Is there in opencv a command allows to save files into a specific folder ?

2016-10-12 04:37:58 -0600 commented answer Skeleton image

How I can print the coordinates of each point neighbours ?

2016-10-12 03:51:39 -0600 commented answer Skeleton image

I use the skeletonization to identify the crack defects in materials. I appreciate your help.

2016-10-12 03:13:51 -0600 commented answer Skeleton image

Thanks a lot, I'll try it.

2016-10-11 08:35:31 -0600 asked a question Skeleton image

You have any idea on how to evaluate the neighboring pixels to define if there is a junction or triple point in a skeleton binary image ?

2016-10-11 08:26:07 -0600 commented answer How save multiple image in a "BOOST_FOREACH" loop

it works fine, thank you very much

2016-10-11 08:18:48 -0600 commented question How save multiple image in a "BOOST_FOREACH" loop

there is another way other than the BOOST loop ?

2016-10-11 08:08:04 -0600 asked a question How save multiple image in a "BOOST_FOREACH" loop

I have written the snippet code below to save multiple images with different names but it doesn't work. Thanks in advance for your help.

#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <sstream>

 ........
 int nBlur[] = {5, 7, 13};
 BOOST_FOREACH( int i, nBlur)
{
    std::string str = boost::lexical_cast<std::string>(i); // convert i to string
    string imgF = "imgBlur" + i;
    const char *imgFile = imgF.c_str();

    GaussianBlur(imgGray, imgGrayBlur, Size(i,i), 0, 0 );
    //imshow("Blurring image", imgGrayBlur);
    Mat blurred(imgGrayBlur);
    imwrite(imgFile+".png", imgGrayBlur);
}
2016-09-26 02:23:39 -0600 received badge  Enthusiast
2016-08-09 03:13:42 -0600 asked a question Skeleton_triple-points

I've a question about the skeletonization forms, have you an idea on how to detect the triple points and the junction in order to remove them, the aim is to calculate the length of segments inside a image.

2016-08-07 14:49:59 -0600 received badge  Scholar (source)
2016-08-07 11:57:20 -0600 answered a question Opencv_contourArea

I've rewritten the code, the idea is to apply a filter by using a mask and then remove the pixels already accounted. Below the complete program. I have tested the code it works fine for objects having a straight line forms but for others forms like as circular I had some inaccurate results.

 #include <iostream>
 #include <iomanip>
 #include <opencv2/opencv.hpp>
 #include "opencv2/imgproc/imgproc.hpp"

 using namespace std;
 using namespace cv;

 int main(int, char** argv){
    // Load source image
    Mat imgSource = imread(argv[1]);
    // Check if image is loaded fine
    if(!imgSource.data)
        cerr << "Add file name image !" << endl;
    // Show source image
    imshow("imgSource", imgSource);
    //Transform source image to gray if it is not
    Mat gray;
    if (imgSource.channels() == 3)
    {
        cvtColor(imgSource, gray, CV_BGR2GRAY);
    }
    else
    {
        gray = imgSource;
    }
    Mat imgBin, imgBiFilter;
    //threshold(gray, imgBin,0, 255, CV_THRESH_BINARY_INV | CV_THRESH_OTSU);
    threshold(gray, imgBin, 100, 255, 1);   
    // count all pixels of binary image
    for (int row = 0; row < imgBin.rows; row++)
    {
        for (int col = 0; col < imgBin.cols ; col++)
        {
            int pixelValue = imgBin.at<uchar>(row,col);
        }
    }
    //Total number of pixels
    int imgResol;
    imgResol = (imgBin.rows * imgBin.cols);
    vector<Point> pixel_contour;   // output, locations of non-zero pixels
    cv::findNonZero(imgBin, pixel_contour);
    //imshow("binary", imgBin);

    vector<Vec4i> hierarchy;
    vector<vector<Point> > contours;
    // extract only the external contour
    findContours(imgBin.clone(), contours, hierarchy, CV_RETR_EXTERNAL,
                 CV_CHAIN_APPROX_NONE);
   // draw the contours as a solid and create a mask of the object
    Mat mask = Mat::zeros(imgBin.size(), CV_8UC1);
    const int arrSize = contours.size();
    double arrArea[arrSize] ;
      for(size_t i = 0; i < contours.size(); i++)    {
       drawContours(mask, contours, i, Scalar(255, 255, 255),
                     CV_FILLED, 8, hierarchy, 0, Point());
    //imshow("mask", mask);
    vector<Point> all_pixels;   // output, locations of non-zero pixels
    cv::findNonZero(mask, all_pixels);
    //count pixel of objects
    int pixelR = pixel_contour.size() - all_pixels.size() ;
    double area = contourArea(contours[i]);

            //Select the range of areas to be considered
            if(area < 5 || 1e4 < area) continue;
            //cout << " pixelR: " << pixelR<< endl;
            drawContours(imgSource, contours, static_cast<int>(i), Scalar(0, 0, 255), 1,
                         8, hierarchy, 0);
            arrArea[i] = pixelR;
    }

    cout << "Ncont" << setw(7) << "Area" << endl;
    for(int j=0; j <contours.size(); j++)
    {
      if (j <=0 )
        {
          cout << j << setw(9) << fabs(arrArea[j] - pixel_contour.size()) << endl;
        }
        else
        {
            cout << j << setw(9) << fabs(arrArea[j] - arrArea[j-1]) <<endl;
        }
    }


    //waitKey(0);
    return 0;
}
2016-08-05 05:58:12 -0600 received badge  Editor (source)
2016-08-05 05:57:18 -0600 asked a question Opencv_contourArea

HI,

When I calculate the area of via the contourArea function in binary image, I'm not getting the correct contour area. Below the snippet code, why the area is calculated incorrectly ? I have used a contour mask but it doesn't solve the problem.

vector<Vec4i> hierarchy;
vector<vector<Point> > contours;

//findContours(bw, contours, hierarchy, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
findContours(bw, contours, hierarchy, CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
Mat mask = Mat::zeros(bw.size(), CV_8UC1);

for (size_t i = 0; i < contours.size(); ++i)
{

drawContours(mask, contours, i, Scalar(255, 255, 255),
                 CV_FILLED, 8, hierarchy, 0, Point());

vector<Point> all_pixels;   // output, locations of non-zero pixels
cv::findNonZero(mask, all_pixels);

vector<Point> all_pixels;
cv::findNonZero(mask, all_pixels);
int inside_phase = all_pixels.size() - contours.size();
    // Calculate the area of each contour
    double area = contourArea(contours[i], true);

    cout << " Area#" << i <<": " << area << endl;
    cout << " inside: " << inside_phase << endl;
}
2016-07-21 04:13:15 -0600 asked a question opencv_error_code-215_channels

Hi, Does anyone know why I'm getting the error message below : Thanks,

OpenCV Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in copyTo, file /home/.../opencv/opencv-3.1.0/modules/core/src/copy.cpp, line 257 terminate called after throwing an instance of 'cv::Exception' what(): /home/.../opencv-3.1.0/modules/core/src/copy.cpp:257: error: (-215) channels() == CV_MAT_CN(dtype) in function copyTo