0

i want to image border via bitmap but some pixel remaining in draw border how can i cover all border pixel in image?

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;

        }
}
James South
  • 10,147
  • 4
  • 59
  • 115
Genish Parvadia
  • 1,437
  • 3
  • 17
  • 30
  • You are comapring for equality. This will only work well if there is __no anti-aliasing__ in the pixels.. – TaW Jun 20 '18 at 08:21
  • 1
    Also: It seems you are not looking for 'image border(s)' but want to do 'edge detection'. – TaW Jun 20 '18 at 08:42
  • I think you need canny edge detection using EmguCV – user8190410 Jun 20 '18 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 '18 at 07:16
  • More details on a general edge-detection algorithm can be found [here](https://stackoverflow.com/a/50282882/395685). – Nyerguds Jun 21 '18 at 07:22
  • btw, your error (from the image) seems to be that you are just detecting stuff above and under your current pixels, but not to the left or right. – Nyerguds Jun 28 '18 at 13:13

0 Answers0