Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

How can I split these characters for character recognition?

$
0
0
I want to split the following characters for character recognition. How can I achieve my goal? ![image description](/upfiles/14532592383015201.jpg) ![image description](/upfiles/14532592766023737.jpg) 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<(y, x) == p) { outImg.at(y, x) = colorPix[p]; break; } } } } return outImg; My resulting images are different in colors. I don't know whether I have done something wrong... ![image description](/upfiles/14532851491282307.jpg) ![image description](/upfiles/14532851594549449.jpg)

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>