Ask Your Question
1

Applying HoughLine correctly on the Region Of Interest within the Picture

asked 2014-04-09 08:17:10 -0600

Henry D gravatar image

updated 2014-04-09 08:34:15 -0600

image description image description

The region of interest are on the dash lines and the right lane. The idea is to draw the line exactly where it is on the picture not on the region of interest of course. I am aware of that coordinates used for drawing the lines are from the region of interest which is why they are positioned wrong, hence "Title".

http://pastebin.com/TKBjtB9T

Any advice are appreciated! ^^

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2014-04-09 09:21:37 -0600

wuling gravatar image

updated 2014-04-09 10:17:22 -0600

My propose is:

  1. Color to Gray, then use threshold, and thresvalue:240~255

  2. use Morphy methold to remove the region cross the left side. and you can get you want.

    void CV_EXPORTS MorpRemoveBoderObj(InputArray _src, OutputArray _dst,InputArray se) { Mat src=_src.getMat(); _dst.create(src.size(),CV_8UC1); Mat dst=_dst.getMat(); Mat sem=se.getMat(); if(sem.empty()) sem= cv::getStructuringElement(MORPH_CROSS,cv::Size(3, 3),cvPoint(-1,-1)); cv::Mat temp; temp.create(src.size(),CV_8UC1); temp.setTo(0); cv::rectangle(temp, cv::Point(3,3), cv::Point(temp.cols-3, temp.rows-3), CV_RGB(255,255,255), -1); // --->here you must reserve only left side, not a rectangle cv::subtract(255,temp,temp); MorpRDilate(temp, src, dst,sem,-1); cv::subtract(src, dst, dst); }

    void CV_EXPORTS MorpRDilate(InputArray _src, InputArray _mask, OutputArray _dst, InputArray se ,int iterations) { Mat src=_src.getMat(); _dst.create(src.size(), src.type()); Mat dst = _dst.getMat(); Mat sem=se.getMat(); if(sem.empty()) sem= cv::getStructuringElement(MORPH_CROSS,cv::Size(3, 3),cvPoint(-1,-1)); Mat mask=_mask.getMat(); //imshow("src",src); //imshow("mask",mask); CV_Assert(src.cols==mask.cols && src.rows == mask.rows); assert(src.cols == mask.cols && src.rows == mask.rows ); if(iterations < 0) { cv::min(src, mask, dst); cv::dilate(dst, dst, sem); cv::min(dst, mask, dst); Mat temp1,temp2; temp1.create(src.size(),CV_8UC1); temp2.create(src.size(),CV_8UC1); do { temp1=dst.clone(); cv::dilate(dst, dst, sem); cv::min(dst, mask, dst); cv::compare(temp1, dst, temp2, CV_CMP_NE ); /imshow("temp1",temp1); imshow("dst",dst); imshow("temp2",temp2);/ } while(cv::sum(temp2).val[0] != 0); //return; } else if (iterations == 0) { dst=src.clone(); //cvCopy(src, dst); } else { cv::min(src,mask,dst); cv::dilate(dst,dst,sem); cv::min(dst,mask,dst); for(int i=1; i<iterations; i++)="" {="" cv::dilate(dst,="" dst,="" sem);="" cv::min(dst,="" mask,="" dst);="" }="" }="" }<="" p="">

edit flag offensive delete link more

Comments

Hi wuling thanks for answering! when you say morphy Methold did you refer to the morphologyEX method? http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=morphologyex#morphologyex

Henry D gravatar imageHenry D ( 2014-04-09 09:48:33 -0600 )edit

yes,but it's no so eiasy. i give you the code in function MorpRemoveBoderObj :cv::rectangle(temp, cv::Point(3,3), cv::Point(temp.cols-3, temp.rows-3), CV_RGB(255,255,255), -1); -->you must retain left side.

wuling gravatar imagewuling ( 2014-04-09 10:19:57 -0600 )edit

Question Tools

Stats

Asked: 2014-04-09 08:17:10 -0600

Seen: 893 times

Last updated: Apr 09 '14