In Android App,I have to detect text lines in images.I want to use Hough Transform
to detect lines.You can see an image below:
I got edges in image by canny
filter,then I applied Hough Transform on canny image:
Size size = canny.size();
Mat lines = new Mat();
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(canny, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);
Result for above image, looks like this:
You can see tree text lines are detected.So I added line's thickness by applying dilate
on canny image:
Mat dilate = new Mat();
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(10,10));
Imgproc.dilate(canny, dilate, kernel);
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(dilate, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);
I drew detected lines on empty black background.Result is shown below:
You can see number of detected text lines is decreased,although I had added thickness of lines and did not change amount of minLineLength or maxLineGap,also when I apply dilation no white pixel remove from image!
Again I added thickness of lines by doing dilation with kernel of size(30,30):
Mat dilate = new Mat();
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(30,30));
Imgproc.dilate(canny, dilate, kernel);
int lineGap = 20;
double sum1 = 0;
Imgproc.HoughLinesP(dilate, lines, 1, Math.PI / 180, 100, size.width / 2.f, lineGap);
Result is:
Now my question is:
Why in each level when I add number of white pixels and do not change minLineLength or maxLineGap,Hough Transform do not detect some lines that were detected in previous level?