Hello everyone, I have written a code to detect edges using double thresholding,what i am doing here is if the higher threshold image has a pixel value of 255 then it is valid and if the lower thrsehold image has a connected white pixel to that pixel then it is valid edge. but in my program only the high threshold image is getting copied.The low threshold valid pixels are not getting drawn.moreover this code is working for larger images not smaller images i really cant understant y because i have nowhere hardcoded the values of the width and height.
here is my code
void edge_linking(ImgGray img_low,ImgGray img_high,ImgGray *img_edge_link,int mu)
{
int x,y;
CPoint p;
vector<Point>edgelink;
for(y=mu;y<=(*img_edge_link).Height()-mu;y++)
{
for(x=mu;x<=(*img_edge_link).Width()-mu;x++)
{
//if(x>0 && y>0 && x< (*img_edge_link).Width()-1 &&(*img_edge_link).Height()-1)
//{
if(img_high(x,y)==255)
{
(*img_edge_link)(x,y)=255;
edgelink.push_back(Point(img_high(x,y)));
while(!edgelink.empty())
{
p=edgelink.back();
edgelink.pop_back();
if (p.x >0 && img_low(p.x-1,p.y)==255 && (*img_edge_link)(p.x-1,p.y)!=255 )
{
(*img_edge_link)(p.x-1,p.y)=255;
edgelink.push_back(Point(p.x-1,p.y));
}
if (p.y>0 && img_low(p.x,p.y-1)==255 && (*img_edge_link)(p.x,p.y-1)!=255)
{
(*img_edge_link)(p.x,p.y-1)=255;
edgelink.push_back(Point(p.x,p.y-1));
}
if (p.x<(*img_edge_link).Width()-1 && img_low(p.x+1,p.y)==255 && (*img_edge_link)(p.x+1,p.y)!=255)
{
(*img_edge_link)(p.x+1,p.y)=255;
edgelink.push_back(Point(p.x+1,p.y));
}
if (p.y <(*img_edge_link).Height()-1 && img_low(p.x,p.y+1)==255 && (*img_edge_link)(p.x,p.y+1)!=255 )
{
(*img_edge_link)(p.x,p.y+1)=255;
edgelink.push_back(Point(p.x,p.y+1));
}
if (p.x>0 && p.y<(*img_edge_link).Height()-1 && img_low(p.x-1,p.y+1)==255 && (*img_edge_link)(p.x-1,p.y+1)!=255)
{
(*img_edge_link)(p.x-1,p.y+1)=255;
edgelink.push_back(Point(p.x-1,p.y+1));
}
if(p.x>0 && p.y>0 && img_low(p.x-1,p.y-1)==255 && (*img_edge_link)(p.x-1,p.y-1)!=255)
{
(*img_edge_link)(p.x-1,p.y-1)=255;
edgelink.push_back(Point(p.x-1,p.y-1));
}
if(p.y<(*img_edge_link).Height()-1 && p.x<(*img_edge_link).Width()-1 && img_low(p.x+1,p.y+1)==255 && (*img_edge_link)(p.x+1,p.y+1)!=255)
{
(*img_edge_link)(p.x+1,p.y+1)=255;
edgelink.push_back(Point(p.x+1,p.y+1));
}
if(p.y>0 && p.x<(*img_edge_link).Width()-1 && img_low(p.x+1,p.y-1)==255 && (*img_edge_link)(p.x+1,p.y-1)!=255)
{
(*img_edge_link)(p.x+1,p.y-1)=255;
edgelink.push_back(Point(p.x+1,p.y-1));
}
}
}
}
}
}