I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
1 | initial version |
I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
2 | here i have posted the code too. it is for line detection. if you have any idea about correcting lines please help me |
I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
int main(int argc, char** argv)
{
IplImage* src = cvLoadImage("110.jpg");
IplImage* dst;
IplImage* color_dst;
IplImage* tempx = cvCreateImage(cvGetSize(src),IPL_DEPTH_16S,1);
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* lines = 0;
int i;
if( !src )
return -1;
dst = cvCreateImage( cvGetSize(src), 8, 1 );
color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
cvCanny( src, dst, 50, 200, 3 );
cvCvtColor( dst, color_dst, CV_GRAY2BGR );
CvSize size = cvGetSize(dst);
lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/45, 50, 50, 10 );
for( i = 0; i < lines->total; i++ )
{
CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
cvLine( color_dst, line[0], line[1], /CV_RGB(255,0,0)/cvScalar(255, 0 ,0), 4, CV_AA, 0 );
}
cvNamedWindow( "Source", 1 );
cvShowImage( "Source", dst );
cvNamedWindow( "Hough", 1 );
cvShowImage( "Hough", color_dst );
cvWaitKey(0);
return 0;
}
3 | No.3 Revision |
I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
int main(int argc, char** argv)
{
IplImage* src = cvLoadImage("110.jpg");
IplImage* dst;
IplImage* color_dst;
IplImage* tempx = cvCreateImage(cvGetSize(src),IPL_DEPTH_16S,1);
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* lines = 0;
int i;
if( !src )
return -1;
dst = cvCreateImage( cvGetSize(src), 8, 1 );
color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
cvCanny( src, dst, 50, 200, 3 );
cvCvtColor( dst, color_dst, CV_GRAY2BGR );
CvSize size = cvGetSize(dst);
lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/45, 50, 50, 10 );
for( i = 0; i < lines->total; i++ )
{
CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
cvLine( color_dst, line[0], line[1], /CV_RGB(255,0,0)/cvScalar(255, 0 ,0), 4, CV_AA, 0 );
}
cvNamedWindow( "Source", 1 );
cvShowImage( "Source", dst );
cvNamedWindow( "Hough", 1 );
cvShowImage( "Hough", color_dst );
cvWaitKey(0);
return 0;
}
4 | Refactor code |
I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
#include "stdafx.h"
#include<opencv\cv.h>
#include<opencv\cxcore.h>
#include<opencv\highgui.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
{
IplImage* src = cvLoadImage("110.jpg"); IplImage* dst;
IplImage* color_dst;
IplImage* tempx = cvCreateImage(cvGetSize(src),IPL_DEPTH_16S,1);
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* lines = 0;
int i;
if( !src )
return -1;
dst = cvCreateImage( cvGetSize(src), 8, 1 );
color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
cvCanny( src, dst, 50, 200, 3 );
cvCvtColor( dst, color_dst, CV_GRAY2BGR );
CvSize size = cvGetSize(dst);
lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/45, 50, 50, 10 );
for( i = 0; i < lines->total; i++ )
{
CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
cvLine( color_dst, line[0], line[1], /CV_RGB(255,0,0)/cvScalar(255, /*CV_RGB(255,0,0)*/cvScalar(255, 0 ,0), 4, CV_AA, 0 );
);
}
cvNamedWindow( "Source", 1 );
cvShowImage( "Source", dst );
cvNamedWindow( "Hough", 1 );
cvShowImage( "Hough", color_dst );
cvWaitKey(0);
return 0;
}