Ask Your Question

alexander33's profile - activity

2020-06-08 19:36:24 -0600 received badge  Popular Question (source)
2019-05-16 08:00:58 -0600 received badge  Famous Question (source)
2018-08-20 04:32:57 -0600 received badge  Notable Question (source)
2018-03-14 02:44:47 -0600 received badge  Popular Question (source)
2017-02-23 11:41:08 -0600 commented answer union of contours opencv

thanks for the response.

2017-02-23 11:40:46 -0600 commented answer union of contours opencv

Thanks a lot for the response, works very fine.

2017-02-22 18:59:54 -0600 asked a question union of contours opencv

I found the contours of one image that content numbers, then I used boundingrect for find the rectangles of those contours the result is:

original img and result

I would know how to unite the final contours for then recognize the letters. the result that i want its something like this:

result that i want

some sugestion for resolve my problem. Thanks"!!!!

2017-02-17 09:33:47 -0600 asked a question Adaptive threshold of blurry images

I have a data set of images and I want make a threshold of them, for this I’ve been using an adaptive threshold, and morphological operations but there are some images like this example with many blur, some idea for to make the digits as clear as possible. I proved the threshold with OTSU, local threshold and adaptive threshold and the results are not good. My code is

Mat plateFinal = imread(".../plate.bmp", 0);

    Mat medianPlate;
    medianBlur(plateFinal, medianPlate, 3);

    Mat clean_img, clean_open, clean_close;
    adaptiveThreshold(medianPlate, clean_img, 255,
        CV_ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 27, 7); 


    Mat element = getStructuringElement(0, Size(3, 3), Point(1, 1));

    // Apply the morphology operation
    morphologyEx(clean_img, clean_open, MORPH_OPEN, element);
    morphologyEx(clean_open, clean_close, MORPH_CLOSE, element);

    imshow("image clean", clean_close);

and the result is:

plate1

plate2

2017-01-25 12:28:38 -0600 asked a question separate contours of text for segmentation

I’ve been working with text recognition in a dataset of images, I want segment the characters of the image using components and finding contours of a threshold image. However, many of the characters are united with each other and others components in the image. Some idea for separate ? Thanks for the help!!!! here some examples, and part of my code:

Mat placa_contornos = processContourns(img_placa_adaptativeTreshold_mean);

vector<vector<Point>> contours_placa;


findContours(placa_contornos,
    contours_placa, // a vector of contours
    CV_RETR_EXTERNAL, // retrieve the external contours (REcupera contornos externos)
    CV_CHAIN_APPROX_NONE); // all pixels of each contours


vector<vector<Point> >::iterator itc = contours_placa.begin();
while (itc != contours_placa.end()) {
    //Create bounding rect of object
    Rect mr = boundingRect(Mat(*itc));
    rectangle(imagem_placa_cor, mr, Scalar(0, 255, 0));
    ++itc;
}

imshow("placa con rectangles", imagem_placa_cor);

examples

2017-01-16 10:48:35 -0600 commented answer insert elements of vector in cols of a mat

Works very fine Thanks......

2017-01-16 10:48:05 -0600 received badge  Critic (source)
2017-01-16 07:40:36 -0600 asked a question insert elements of vector in cols of a mat

I have a vector of floats and i want insert the element of this vector in the cols of the Mat. reading the doc doc of opencv says that when I pass a vector like parameter in the MAt constructor, The matrix has a single column and the number of rows equal to the number of vector elements. I want just that the matrix has a single row and the numbers of cols equal to the number of vector elements.

vector<float> descriptorsValues;
Mat fm = Mat(descriptorsValues);

thanks for the help !!!!!!

2017-01-12 05:15:32 -0600 received badge  Enthusiast
2017-01-09 14:52:48 -0600 answered a question cannot save SVM in OpenCV4Android 3.2 after upgrade: Fatal signal 11

the way like you create the SVM is wrong. since opencv 3.0 changed.

You can see this: http://docs.opencv.org/3.1.0/d1/d73/t... for see one example.

Ptr<SVM> svm = SVM::create();

also i find this explanation, the best that i found. https://www.simplicity.be/article/rec...

good luck!

2016-12-31 04:15:34 -0600 received badge  Supporter (source)
2016-12-31 04:14:59 -0600 commented answer drawning labeling components in a image opencv c++

Thank you, @LBerger, works very fine.....

2016-12-31 04:12:07 -0600 received badge  Scholar (source)
2016-12-30 20:18:10 -0600 asked a question drawning labeling components in a image opencv c++

I have the next image.

original image

I used the function connectedComponentsWithStats for find the components of the image. now i want draw only the components with an area > 3000, in this case there are 3 of the 5 components that the function found, i used the function "compare" for draw the 3 components but the result is not expected (only draw 1 component), Some idea for get the final result? thank you. my result is:

final result

int main(int argc, const char** argv)

{

img = imread("blob.png", 0);

if (img.empty())
{
    cout << "Could not read input image file: " << endl;
    return -1;
}

namedWindow("Image", 1);
imshow("Image", img);

Mat labelImage(img.size(), CV_32S);
Mat stats, centroids;
int nLabels = connectedComponentsWithStats(img, labelImage, stats, centroids, 8, CV_32S);
std::vector<Vec3b> colors(nLabels);
std::vector<int> labels_finals;
colors[0] = Vec3b(0, 0, 0);//background


for (int label = 1; label < nLabels; ++label){ //label  0 is the background
    if ((stats.at<int>(label, CC_STAT_AREA)) > 3000){
        labels_finals.push_back(label);
        //cout << "hola" << endl;
    }

    cout << "area del component: " << label << "-> " << stats.at<int>(label, CC_STAT_AREA) << endl;
    //colors[label] = Vec3b((rand() & 255), (rand() & 255), (rand() & 255));
    colors[label] = Vec3b(0, 255, 0);
}


Mat dst(img.size(), CV_8UC3);
for (int r = 0; r < dst.rows; ++r){
    for (int c = 0; c < dst.cols; ++c){

        int label = labelImage.at<int>(r, c);
        //cout << "label:  " << label << endl; 
        Vec3b &pixel = dst.at<Vec3b>(r, c);//accesa al elemento 
        pixel = colors[label];
    }
}

Mat dst2(img.size(), CV_8UC3);

for (int i = 0; i < labels_finals.size(); ++i){
    std::cout << "path i:  " << labels_finals[i] << ' ' << endl;
    compare(labelImage, labels_finals[i], dst2, CMP_EQ);
}

imshow("compare imagem ", dst2);

}

2016-12-30 20:18:10 -0600 asked a question drawning labeling components in a image opencv

I have the image:

original image

I used the function connectedComponentsWithStats for find the components of the image. now i want draw only the components with an area > 3000, in this case there are 3 of the 5 components that the function found, i used the function "compare" for draw the 3 components but the result is not expected (only draw 1 component), Some idea for get the final result? thank you. my result is:

image description

and my code is:

int main(int argc, const char** argv)

{

img = imread("blob.png", 0);

if (img.empty())
{
    cout << "Could not read input image file: " << endl;
    return -1;
}

namedWindow("Image", 1);
imshow("Image", img);

Mat labelImage(img.size(), CV_32S);
Mat stats, centroids;
int nLabels = connectedComponentsWithStats(img, labelImage, stats, centroids, 8, CV_32S);
std::vector<Vec3b> colors(nLabels);
std::vector<int> labels_finals;
colors[0] = Vec3b(0, 0, 0);//background


for (int label = 1; label < nLabels; ++label){ //label  0 is the background
    if ((stats.at<int>(label, CC_STAT_AREA)) > 3000){
        labels_finals.push_back(label);
        //cout << "hola" << endl;
    }

    cout << "area del component: " << label << "-> " << stats.at<int>(label, CC_STAT_AREA) << endl;
    //colors[label] = Vec3b((rand() & 255), (rand() & 255), (rand() & 255));
    colors[label] = Vec3b(0, 255, 0);
}


Mat dst(img.size(), CV_8UC3);
for (int r = 0; r < dst.rows; ++r){
    for (int c = 0; c < dst.cols; ++c){

        int label = labelImage.at<int>(r, c);
        //cout << "label:  " << label << endl; 
        Vec3b &pixel = dst.at<Vec3b>(r, c);//accesa al elemento 
        pixel = colors[label];
    }
}

Mat dst2(img.size(), CV_8UC3);

for (int i = 0; i < labels_finals.size(); ++i){
    std::cout << "path i:  " << labels_finals[i] << ' ' << endl;
    compare(labelImage, labels_finals[i], dst2, CMP_EQ);
}

imshow("compare imagem ", dst2);

}

thanks

2016-12-30 20:18:09 -0600 asked a question drawning labeling components in a image opencv

I have the image:

original image

I used the function connectedComponentsWithStats for find the components of the image. now i want draw only the components with an area > 3000, in this case there are 3 of the 5 components that the function found, i used the function "compare" for draw the 3 components but the result is not expected (only draw 1 component), Some idea for get the final result? thank you. my result is:

image description

and my code is:

int main(int argc, const char** argv)

{

img = imread("blob.png", 0);

if (img.empty())
{
    cout << "Could not read input image file: " << endl;
    return -1;
}

namedWindow("Image", 1);
imshow("Image", img);

Mat labelImage(img.size(), CV_32S);
Mat stats, centroids;
int nLabels = connectedComponentsWithStats(img, labelImage, stats, centroids, 8, CV_32S);
std::vector<Vec3b> colors(nLabels);
std::vector<int> labels_finals;
colors[0] = Vec3b(0, 0, 0);//background


for (int label = 1; label < nLabels; ++label){ //label  0 is the background
    if ((stats.at<int>(label, CC_STAT_AREA)) > 3000){
        labels_finals.push_back(label);
        //cout << "hola" << endl;
    }

    cout << "area del component: " << label << "-> " << stats.at<int>(label, CC_STAT_AREA) << endl;
    //colors[label] = Vec3b((rand() & 255), (rand() & 255), (rand() & 255));
    colors[label] = Vec3b(0, 255, 0);
}


Mat dst(img.size(), CV_8UC3);
for (int r = 0; r < dst.rows; ++r){
    for (int c = 0; c < dst.cols; ++c){

        int label = labelImage.at<int>(r, c);
        //cout << "label:  " << label << endl; 
        Vec3b &pixel = dst.at<Vec3b>(r, c);//accesa al elemento 
        pixel = colors[label];
    }
}

Mat dst2(img.size(), CV_8UC3);

for (int i = 0; i < labels_finals.size(); ++i){
    std::cout << "path i:  " << labels_finals[i] << ' ' << endl;
    compare(labelImage, labels_finals[i], dst2, CMP_EQ);
}

imshow("compare imagem ", dst2);

}

thanks