How to find image border via bitmap in c#?

Multi tool use
How to find image border via bitmap in c#?
i want to image border via bitmap but some pixel remaining in draw border how can i cover all border pixel in image?
Datatable Data
GetImageDataId PixelName PixelA PixelR PixelG PixelB PixelXCordinate PixelYCordinate
1 ffbcbcbc 255 188 188 188 0 0
2 ffb5b5b5 255 181 181 181 0 1
3 ffb7b7b7 255 183 183 183 0 2
4 ffb7b7b7 255 183 183 183 0 3
5 ffb7b7b7 255 183 183 183 0 4
Code
if (dt1.Rows.Count > 0)
{
int p = 2;
progressBar1.Visible = true;
for (int r = dt1.Rows.Count - 1; r >= 1; r--)
{
if (dt1.Rows[r]["PixelName"].ToString() == "ffb7b7b7")
{
// DataTable dtf = dt1.Select("PixelYCordinate='" + r + "'AND PixelXCordinate ='" + Convert.ToInt32(r - 1) + "'").CopyToDataTable();
// DataTable dtp = dt1.Select("PixelXCordinate='" + r + "'AND PixelYCordinate ='" + Convert.ToInt32(r - 1) + "'").CopyToDataTable();
if (dt1.Rows[r]["PixelName"].ToString() == dt1.Rows[r - 1]["PixelName"].ToString() && dt1.Rows[r]["PixelName"].ToString() == "ffb7b7b7")
{
}
else if (dt1.Rows[r]["PixelName"].ToString() == "ffb7b7b7")
{
for (int k = 0; k < p; k++)
{
b.SetPixel(Convert.ToInt32(dt1.Rows[r]["PixelXCordinate"]), Convert.ToInt32(dt1.Rows[r - k]["PixelYCordinate"]), Color.FromArgb(255, 255, 0, 0));
pictureBox1.Image = b;
}
}
r = r - p - 1;
}
}
Also: It seems you are not looking for 'image border(s)' but want to do 'edge detection'.
– TaW
Jun 20 at 8:42
I think you need canny edge detection using EmguCV
– user8190410
Jun 20 at 15:33
Why are you comparing strings? Just use
0xffb7b7b7
notation of you want to write hex values in your code. btw, "Coordinate" has two o's in it...– Nyerguds
Jun 21 at 7:16
0xffb7b7b7
More details on a general edge-detection algorithm can be found here.
– Nyerguds
Jun 21 at 7:22
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You are comapring for equality. This will only work well if there is no anti-aliasing in the pixels..
– TaW
Jun 20 at 8:21