Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I make this image for character segmentation?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

How can I make this image to be suitable for a character segmentation?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

How can I make this image to be suitable split these characters for a character segmentation?recognition?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

How can I split these characters for character recognition?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

Should I use color clustering or any other methods, since there are four different or similar colors for each character? But I don't know how to do that.

How can I split these characters for character recognition?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

Should I use color clustering or any other methods, since there are four different or similar colors for each character? among characters? But I don't know how to do that.

How can I split these characters for character recognition?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

Should I use color clustering or any other methods, since there are four different or similar colors among characters? But I don't know how to do that.

The following code is to use kmean method to split those characters.

Mat src= imread(name);
cv::Mat reshaped_image = src.reshape(1, src.cols * src.rows);
Mat reshaped_image32f;
reshaped_image.convertTo(reshaped_image32f, CV_32FC1, 1.0 / 255.0);

cv::Mat labels;
int cluster_number = 5;
cv::TermCriteria criteria{ cv::TermCriteria::COUNT, 100, 1 };
cv::Mat centers;
cv::kmeans(reshaped_image32f, cluster_number, labels, criteria, 1, cv::KMEANS_RANDOM_CENTERS, centers);
Mat new_image;

int* clusters_p = (int*)labels.data;

Mat label(src.size(), CV_32SC1);
int* label_p = (int*)label.data;
unsigned long int size = src.cols * src.rows;

for (int i = 0; i < size; i++)
{
    *label_p = *clusters_p;
    label_p++;
    clusters_p++;
}

double minH, maxH;
minMaxLoc(labels, &minH, &maxH);

cout << "minH = "  << minH<<endl;
cout << "maxH = " << maxH << endl;

Mat outImg(src.size(), CV_8UC3);
Vec3b colorPix[5] = { { 221, 37, 49 }, { 242, 130, 54 }, { 241, 234, 84 }, { 182, 228, 33 }, { 0, 164, 228 } };

for (int x = 0; x < label.cols; x++)
{
    for (int y = 0; y < label.rows; y++)
    {
        for (int p = 0; p < 5; p++)
        {
            if (label.at<int>(y, x) == p)
            {
                outImg.at<Vec3b>(y, x) = colorPix[p];
                break;
            }
        }           
    }       
}

Mat label_show;
label.convertTo(label_show, CV_8UC1);
normalize(label_show, label_show, 255, 0, CV_MINMAX);   

return outImg;

My resulting images are different in colors. I don't know whether I have done something wrong...

image description image description

How can I split these characters for character recognition?

I want to split the following characters for character recognition. How can I achieve my goal?

image description image description

Should I use color clustering or any other methods, since there are four different or similar colors among characters? But I don't know how to do that.

The following code is to use kmean method to split those characters.

Mat src= imread(name);
cv::Mat reshaped_image = src.reshape(1, src.cols * src.rows);
Mat reshaped_image32f;
reshaped_image.convertTo(reshaped_image32f, CV_32FC1, 1.0 / 255.0);

cv::Mat labels;
int cluster_number = 5;
cv::TermCriteria criteria{ cv::TermCriteria::COUNT, 100, 1 };
cv::Mat centers;
cv::kmeans(reshaped_image32f, cluster_number, labels, criteria, 1, cv::KMEANS_RANDOM_CENTERS, centers);
Mat new_image;

int* clusters_p = (int*)labels.data;

Mat label(src.size(), CV_32SC1);
int* label_p = (int*)label.data;
unsigned long int size = src.cols * src.rows;

for (int i = 0; i < size; i++)
{
    *label_p = *clusters_p;
    label_p++;
    clusters_p++;
}

double minH, maxH;
minMaxLoc(labels, &minH, &maxH);

cout << "minH = "  << minH<<endl;
cout << "maxH = " << maxH << endl;

Mat outImg(src.size(), CV_8UC3);
Vec3b colorPix[5] = { { 221, 37, 49 }, { 242, 130, 54 }, { 241, 234, 84 }, { 182, 228, 33 }, { 0, 164, 228 } };

for (int x = 0; x < label.cols; x++)
{
    for (int y = 0; y < label.rows; y++)
    {
        for (int p = 0; p < 5; p++)
        {
            if (label.at<int>(y, x) == p)
            {
                outImg.at<Vec3b>(y, x) = colorPix[p];
                break;
            }
        }           
    }       
}

Mat label_show;
label.convertTo(label_show, CV_8UC1);
normalize(label_show, label_show, 255, 0, CV_MINMAX);   

return outImg;

My resulting images are different in colors. I don't know whether I have done something wrong...

image description image description