mercredi 27 novembre 2019

Simpler way of adjusting X/Y values in a 8x25 matrix

I have an image with some patterns. The patterns are arranged in an 8 column x 25 rows format. Im inspecting these patterns and sending the coordinate of defective pattern to a 4 axis robot for marking in a mirror pattern. I have the COG of each pattern, but the marking position is not at center, its a little to the left on left mirror pattern and little to the right on the right mirror pattern.

Ref image below:

enter image description here

In the above image, the red spot is the COG that I have, green spots are the marking area that I need to send to robot.

The height and width of each pattern is the same. So what im doing now is specifying that if the rejection is (> 0pxX and < 30pxX)&& (>0pxY < 15pxY) then subtract the COG by 9, so the marking position shifts 9 px to the left. Code Eg :

 //less than 30 column and 15 row
 if (df1.cog_X >10 && df1.cog_X < 30 && df1.cog_Y >10 && df1.cog_Y <15)
  {
   df1.cog_X = df1.cog_X - Convert.ToInt32(txtrow1.Text);                                   
  }
 // less than 30 column and 15-30 row
 if (df1.cog_X >10 && df1.cog_X < 30 && df1.cog_Y >15 && df1.cog_Y <30)
  {
   df1.cog_X = df1.cog_X - Convert.ToInt32(txtrow2.Text);                                   
  }
 // less than 30 column and 30-45 row
 if (df1.cog_X >10 && df1.cog_X < 30 && df1.cog_Y >30 && df1.cog_Y <45)
  {
   df1.cog_X = df1.cog_X - Convert.ToInt32(txtrow3.Text);                                   
  }
  ......and so on.

But this is a long process and I have to do it for an 8x25 matrix which means I have to write if statements 200 times, which in turn increases the processing time.'

Is there a simpler way to do it?

Aucun commentaire:

Enregistrer un commentaire